Data integrity · השלמותיות של הנתונים
Keeping data correct
- Integrity means data stays accurate. Two techniques protect it: validation and verification.
- They sound similar but do different jobs — a classic exam distinction.
שמירה על נכונות הנתונים
- שלמות אומרת שהנתונים נשארים מדויקים. שתי טכניקות מגנות עליהן: אימות ו-בדיקה.
- הן נשמעות דומה אך מבצעות משימות שונות — הבחנה קלאסית במבחנים.
Validation vs verification
- Validation checks data is reasonable as it is entered. Examples:
- Range check (age 0–120), length check (a phone number), format check (an email has an
@), presence check (not left blank).
- Range check (age 0–120), length check (a phone number), format check (an email has an
- Verification checks data was copied correctly. Examples:
- Double entry (type a password twice), or a visual check (read it back).
אימות לעומת בדיקה
- אימות בודק שהנתונים סבירים בזמן הכניסה שלהם. דוגמאות:
- בדיקת טווח (גיל 0–120), בדיקת אורך (מספר טלפון), בדיקת פורמט (כתובת דוא"ל מכילה
@), בדיקת נוכחות (לא נותרה ריקה).
- בדיקת טווח (גיל 0–120), בדיקת אורך (מספר טלפון), בדיקת פורמט (כתובת דוא"ל מכילה
- בדיקה בודקת שהנתונים הועתקו נכון. דוגמאות:
- הקלדה כפולה (הקלידו סיסמה פעמיים), או בדיקה ויזואלית (קראו אותה חזרה).
Checking data in transit
- When data travels, bits can flip. A checksum or check digit catches that.
- The sender calculates a small number from the data; the receiver recalculates it. If they differ, the data was corrupted.
בדיקת נתונים במעבר
- כאשר נתונים מועברים, ביטים עשויים להסתובב. סך ביקורת או ספרת ביקורת חושפת זאת.
- השולח מחשב מספר קטן מהנתונים; המקבל מחשב אותו מחדש. אם הם שונים, הנתונים פגומים.
number = "1389"
print(sum(int(d) for d in number) % 10) # a one-digit checksum
Your turn
- Compute a simple check digit by summing the digits modulo 10. Real systems (like barcodes and ISBNs) use cleverer versions of this idea.
Covers: A-Level 6.2 (validation/verification), IGCSE 2.2 (error detection).
תורך
- לחשב ספרת ביקרת פשוטה על ידי סיכום הספרות מודולו 10. מערכות אמיתיות (כמו ברקודים ו-ISBNs) משתמשות בגרסאות מתוחכמות יותר של רעיון זה.
מכסה: A-Level 6.2 (תוקף/נכונות), IGCSE 2.2 (זיהוי שגיאות).
Common mistakes
- A checksum or check digit spots accidental changes to data.
- Validation checks data is sensible; verification checks it was entered correctly.
טעויות נפוצות
- סך ביקורת או ספרת ביקורת זורקים אצבע על שינויים מקריים בנתונים.
- תוקף בוודא שהנתונים הגיוניים; נכונות בוודא שהם הוזנו בצורה הנכונה.
Hashes detect tampering · חשיבות גלויות התערבות
Re-hash the data and compare: any change flips the digest. · חשב חשיבה מחדש והשוו: כל שינוי משנה את החשיבה.
A simple checksum helps catch typing errors. Add up the digits of number and take the result modulo 10. Print that single check digit. · סכום בדיקה פשוט עוזר ללכוד שגיאות הקלדה. סכם את הספרות של number ולקח את התוצאה מודולו 10. הדפס את ספרת הבדיקה היחידה הזו.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Now be the receiver. The sender transmitted the digits with check digit 8, but one digit got corrupted on the way. Recompute the checksum of received and print ERROR if it does not equal sent_check, else OK. · עכשיו תהיה המקבל. השולח העביר את הספרות עם ספרת הבדיקה 8, אך ספרה אחת נפגעה בדרך. חשב מחדש את סכום הבדיקה של received והדפס ERROR אם הוא אינו שווה לsent_check, אחרת הדפס OK.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.