RELATIONAL MODEL III
CONTENT
- Enforcing Integrity Constraints
- Querying Relational Data
Enforcing Integrity Constraints
We will consider the following constraints:
SQL NOT NULL Constraint
The following SQL enforces student_id and Firstname column to not accept NULL values:
CREATE TABLE student
(
Student_id int NOT NULL,
FirstName varchar(255) NOT NULL,
LastName,
Age,
Class,
Scores
)
SQL UNIQUE KEY Constraint
The following SQL enforces gsm_no column not to accept duplicate values on the teachers’ table below. Meaning two teachers cannot be sharing one gsm_no
CREATE TABLE teachers
(
teacher_id int NOT NULL,
FirstName varchar(255) NOT NULL,
LastName,
Age,
email_address,
gsm_no int(11) UNIQUE KEY
)
SQL PRIMARY KEY Constraint
The following SQL constraint uniquely identifies each record in a database table. It must contain unique values. Each table should have a primary key and cannot be NULL. In most cases, the id is used as the primary key so we will enforce it on the teacher_id in the SQL syntax below.
- NEW: Download the entire term's content in MS Word document format (1-year plan only)
- The complete lesson note and evaluation questions for this topic
- The complete lessons for the subject and class (First Term, Second Term & Third Term)
- Media-rich, interactive and gamified content
- End-of-lesson objective questions with detailed explanations to force mastery of content
- Simulated termly preparatory examination questions
- Discussion boards on all lessons and subjects
- Guaranteed learning