(SQL2) نظري 1 PDF
(SQL2) نظري 1 PDF
Advanced Database
LECTURE 1
Relational Data Model
8-Nov-22
What is a Data Model?
A notation for describing data or information
Description consists of 3 parts:
1) Structure of the data
8-Nov-22
Basics of the Relational Model
1-4
`
8-Nov-22
Basics of the Relational Model
1-5
8-Nov-22
Keys of Relations
1-6
8-Nov-22
1-7
Candidate Key :
A Candidate Key can be any column or a
combination of columns that can qualify as
unique key in database.
There can be multiple Candidate Keys in one
table.
Each Candidate Key can qualify as Primary
Key.
8-Nov-22
1-8
Primary key:
A Primary Key is a column or a combination of
columns that uniquely identify a ROW. Only one
Candidate Key can be Primary Key.
8-Nov-22
1-9 D# Dname Chairman City
11 Sales Ahmed Misurata
12 Account Ali Tripoli
22 Research Sara Tripoli
Department table
8-Nov-22
1-
8-Nov-22
Integrity Rules
1-12
1- Entity integrity
exists when each primary key within a table has
a value that is unique.
This ensures that each row is uniquely identified
8-Nov-22
1-13
2- Reference integrity
Is the relational property that each foreign key value in a table
exists as a primary key in the referenced table.
COURSE
C# CCODE CREDITS
20 CS 701 3
25 CS 705 4
35 CS 503 3
36 MA 101 3
Department C# is the primary key
D# Dname City C#
10 Cs Misurata 20
12 Math Tripoli 36 C# is the foreign key 8-Nov-22
1-14
3- Domain integrity
Specify that all columns in a database must be
declared upon a defined domain. A domain is a set
values of the same value type.
8-Nov-22
Functional dependencies
– Functional Dependencies
– Primary Keys
8-Nov-22
The Normalization of Relations
8-Nov-22
• Set-valued attributes
Non atomic
values
Createnew relation
Columns = Key + multi-valued
8-Nov-22
Solution
8-Nov-
22 22
Second Normal Form (2NF)
8-Nov-22
1-24
Solution
8-Nov-22
Third Normal Form (3NF)
8-Nov-22
25
Non 3NF Relation
26
Solution
8-Nov-22
The End
8-Nov-22