DB - Chapter 2
DB - Chapter 2
The relational database uses a collection of tables to represent both data and the
relationships among those data
Table/Relation
● Tables are database objects that contain all the data in a database.
● In tables, data is logically organized in a row-and-column format similar
to a spreadsheet.
Relation : Employee
Example:
The Employee table contain the following row:
101, Ali, 32203-8659771-5, 50000, 0347-5628911, [email protected]
Column/Attribute/Field
Row/Record/Tuple
Degree, Cardinality
● Like a superset
● All possible keys that can be formed in a relation.
● Should be unique and not contain null values.
● May contain extraneous attributes.
Super Key
● Example:
{E_ID}, {E_CNIC},
{E_ID, E_CNIC} , {E_ID, E_NAME}, {E_ID, E_PHONE}, {E_NAME,
E_PHONE},{E_ID, E_EMAIL}
{E_NAME, E_CNIC, E_PHONE}, {E_ID, E_NAME, E_PHONE}
…..
Candidate Key
● Minimal
● Accessible
● NON NULL Value
● Time Invariant
● Unique
Alternate Key
Primary Key
D_ID D_NAME LOCATION
Department
41 IT Karachi
42 HR Islamabad
43 Marketing Karachi
Maintaining Data Integrity
Can we add a new record with D_ID 45? D_ID D_NAME LOCATION
Department
41 IT Karachi
42 HR Islamabad
43 Marketing Karachi
Referential Integrity
● Referential integrity is a data quality concept that ensures that when you
make changes to data in one place, those changes are reflected in other
related records.
Referential Integrity
{P_ID, E_ID}
Relation: Department_Manager
{P_ID, E_ID}