Databases
Define entity integrity in terms of a relational database.
- Every table must have a primary key.
- The primary key must be unique and not null.
How to entity integrity may prevent the insertion of a row of data into a table.
- No two rows of data can be identical.
- An attempt to insert a row of data that already exists in the table will be prevented.
How to entity integrity is implemented in a relational database.
- A primary key should be declared in the CREATE TABLE statement
- The primary key should be UNIQUE and NOT NULL
Define referential integrity in terms of a relational database.
- Relates to the foreign key which must exist in one of two states.
- Foreign key must exist as a primary key in another table
- Or, in certain circumstances, be null
How to referential integrity may prevent the insertion of a row of data into a table.
- If foreign key is entered that does not exist as a primary key in the defined table.
- Or null entry for foreign key when it is defined as not null.
How to referential integrity is implemented in a relational DBMS.
- The foreign key(s) should be declared in the CREATE TABLE statement.
- The foreign key(s) specification identifies the associated table and should be mandatory (NOT NULL)
- The foreign key(s) specification identifies the propagation constraints (ON DELETE SET NULL, ON UPDATE CASCADE)
How the following propagation constraints can be used to maintain referential integrity:
Restricted delete
- Target rows cannot be deleted until all module rows for that foreign key have been deleted from the related table.
Cascades delete
- If a target row is deleted, all related rows in the related table are deleted.
Nullifies delete
- If a target row is deleted, all associated foreign key values in the related table are set to null.
Post a Comment
0 Comments
Keyword Enter Here