Table (i)Student (student table )
Add PRIMARY KEY constraint number Sno
Table (ii) Course (curriculum)
Add a PRIMARY KEY constraint course number con, add foreign KEY constraint faculty number ton
Table (iii) score (score table)
Add two foreign KEY constraint number Sno and course number Cno, the PRIMARY KEY constraint is sno+ Cno.
Table (iv) Teacher (Teacher's table)
Add PRIMARY KEY constraint faculty number TNO
PRIMARY KEY constraint:
1. The primary KEY constraint contains a non-null constraint with a unique constraint, only one;
2. A single row of data can be determined by the primary key column;
3. Automatically generate index according to primary key column, improve data retrieval efficiency;
4. Ensure that the uniqueness of the data is also normative.
CHECK constraints: Qualify the size and list by checking the rule statements.
FOREIGN KEY constraints:
1. The linkage between two tables is also a constraint relationship between two tables;
2. Settings: Set this field foreign key, must be associated to other tables with unique constraints on the fields, the general setting of the foreign key is the primary key on the table to be associated. Field names can be distinct, but data types are the same;
3. Ensure data integrity: when adding or modifying the foreign key field contents of the Foreign key table, the content must exist in the corresponding field in the primary key table. That is, to change the foreign key must first of its associated with a unique constraint field to get rid of;
4. When you modify the contents of the key in the primary key table, the fields in the Foreign key table are deleted first.
Add primary key and foreign key