Computer Science – 6.2 Data Integrity | e-Consult
6.2 Data Integrity (1 questions)
The 'Courses' field in a student database likely stores the names of courses the student is enrolled in. To ensure data integrity, several data validation methods should be employed:
Data Type Validation: The 'Courses' field should be defined as a string data type (e.g., VARCHAR). This prevents the entry of numerical or other incompatible data. If a user attempts to enter a number, the system should reject the input and display an appropriate error message.
Format Checking: While not strictly necessary for course names, format checking can be useful if the system requires courses to follow a specific naming convention (e.g., "CS101 Introduction to Computer Science"). Regular expressions can be used to enforce this format. This ensures consistency in course naming.
Lookup Table (or Controlled Vocabulary): This is the most important validation method. A lookup table (or a controlled vocabulary) should be maintained containing a list of all valid courses offered by the institution. When a student is adding courses, the system should compare the entered course name against this table. If the course name is not found in the table, the system should reject the input and inform the user that the course is invalid. This prevents typos and ensures that only officially offered courses are recorded.
Example Validation Process:
- The user enters a course name (e.g., "Math 201").
- The system checks if the data type is a string.
- The system checks if the course name exists in the lookup table.
- If both checks pass, the course name is accepted and stored.
- If either check fails, an error message is displayed to the user, prompting them to correct the input.