Académique Documents
Professionnel Documents
Culture Documents
Chapter Outline
Basic Concepts
Keys
Integrity Rules
Indexes
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Chapter Objectives
Explain the no action, restrict, set to null, set default and cascade rules for reference
rows
Basic Concepts
The relational model was first proposed by E. F. Codd in his seminal paper ‘A
relational model of data for large shared data banks’ (Codd, 1970).
Files are vulnerable to changes, often not shared which could lead
to data redundancy and hard to retrieved if there are damages to
the files.
Record type - a structural description of each and every record in the file
Files vs Relations
FILES RELATIONS
Meaning of data WILL BE Meaning of data will NOT be
AFFECTED if the column is affected if the column is rearranged
rearranged to another order to another order
Relational Keys
Superkey
Candidate Key
Primary Key
Alternate Key
Foreign Key
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
SUPERKEY
CANDIDATE
KEY
PRIMARY KEY
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Superkey:
Candidate Key:
Alternate Key:
Alternate Key is a candidate key that was not chosen to be the primary
key of the relation.
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Integrity Rules
Integrity constraints is to make sure that the data is accurate.
The two principal rules for the relational model are known as entity
integrity and referential integrity.
Entity Integrity
The first integrity rule applies to the primary keys of base relations.
studentID cannot be null as it is the determinant for the other attributes like
studentName, studentAddress etc.
Hence, a primary key cannot be null and this kind of rule is called entity
integrity.
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Referential Integrity
The second integrity rule applies to foreign keys.
For example, branchNo in the Staff relation is a foreign key targeting the
branchNo attribute in the home relation, Branch.
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Delete rules
Insert rules
Update rules
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
SET NULL: If the configured action is "SET NULL", then when a parent
key is deleted (for ON DELETE SET NULL) or modified (for ON UPDATE
SET NULL), the child key columns of all rows in the child table that
mapped to the parent key are set to contain SQL NULL values.
SET DEFAULT: The "SET DEFAULT" actions are similar to "SET NULL",
except that each of the child key columns is set to contain the columns
default value instead of NULL.
For an "ON DELETE CASCADE" action, this means that each row in the
child table that was associated with the deleted parent row is also
deleted.
For an "ON UPDATE CASCADE" action, it means that the values stored
in each dependent child key are modified to match the new parent key
values.
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Contains (at least) all the attribute names and characteristics for
each table in the system
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
System catalog
Contains metadata
Detailed system data dictionary that describes all objects within the
database
Terms “system catalog” and “data dictionary” are often used
interchangeably
Can be queried just like any user/designer-created table
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Relationships
There are binary and ternary relationships in DBMS.
Binary means there are 2 entities connected to each other and ternary
means 3 entities connected to each other.
One-to-one relationship
One-to-many relationship
Many-to-many relationship
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Ternary Relationship
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Unary Relationship
Author: Muhammad Hamiz Mohd Radzi Edited By: Zuhri Arafah Zulkifli
Index
Orderly arrangement to logically access rows in a table
Unique index: Index key can have only one pointer value
associated with it
References
Database Systems: Design, Implementation, & Management, 7th Edition, Rob &
Coronel