06-The Relational Database Terminology
06-The Relational Database Terminology
Terminology
1
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
2 Lecture outline
Relational Database Model Terminology
Integrity Constraints
Domain Integrity Constraints
Entity Integrity Constraints
Referential Integrity Constraints
Relational Model Keys
Example Relations
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
3 Relational Model Terminology
Column /
Attribute /
Field
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
4 Equivalent Sets of Terms
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
5
Integrity Constraints
We have defined three constraints so far in our discussion:
The domain integrity constraint
The entity integrity constraint
The referential integrity constraint
The purpose of these three constraints, taken as a whole, is to create database
integrity, which means that the data in our database will be useful, meaningful
data.
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
6 The Domain Integrity Constraint
It means that all of the values in a column are of the same kind.
The term domain means a grouping of data that meets a specific type
definition.
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
7 The Entity Integrity Constraint
Each row must have a unique data value indicated with a primay or
composite key.
It is a fundamental requirement for the proper functioning of a relational
database.
Student_ID First_Name Department Phone Address
100 Ahmad IS 0786778899 Khost
101 Shaheen IT 0700800900 Khost
Unique values 102 Mohsin IT 0777885885 Paktika
103 Kamal IS 0765889944 Khost
104 Rahim IS 0799454545 Logar
105 Rashid IT 0789123456 Nangarhar
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
The Referential Integrity Constraint
8 If a value of one attribute of a relation references a value of another attribute
in another relation, then the referenced value must exist.
It states that the table relationships must always be consistent.
Student Relation
Std_ID First_Name Dept Phone Address
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
9
Relational Model Keys
A key is one or more columns of a relation that is used to identify a row.
A key can be unique or nonunique.
Types of Keys
Surrogate Key
Composite Key
Candidate Key
Primary Key
Foreign Key
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
10
Surrogate Key
A surrogate key is a column with a unique, DBMS-assigned identifier that
has been added to a table to be the primary key.
The unique values of the surrogate key are assigned by the DBMS each
time a row is created, and the values never change.
Surrogate Key
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
11 Composite Key
A key that contains two or more attributes is called a composite key.
For example, suppose that we are looking for a unique key for the
EMPLOYEE relation, and the users say that although LastName is not
unique, the combination of LastName and Department is unique.
Thus, for some reason the users know that two people with the same last name
will never work in the same department. Two Johnsons, for example, will
never work in accounting.
If that is the case, then the combination (LastName, Department) is a unique
composite key.
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
12 Candidate and Primary Keys
Candidate keys are keys that uniquely identify each row in a relation.
Candidate keys can be single-column keys, or they can be composite keys.
The primary key is the candidate key that is chosen as the key that the DBMS
will use to uniquely identify each row in a relation.
For example, suppose that we have the following EMPLOYEE relation:
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
13 Defining a Primary Key in MS Access
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
Foreign Key
14 We place values from one relation into a second relation to represent a relationship.
The values we use are the primary key values of the first relation.
When we do this, the attribute in the second relation that holds these values is referred to
STUDENT Relation as a foreign key.
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
15
Enforcing Referential Integrity in MS Access
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023
16
Thank You!
Instructor: Najib Ullah Sadaat | Email: [email protected] | Linked In, Twitter, Instagram: @NajeebSadaat | Contacts: 07(0,6,8)6 24 90 24 11/24/2023