Professional Documents
Culture Documents
سلايدات قواعد بيانات PDF
سلايدات قواعد بيانات PDF
Data:
Known facts that can be recorded and have an implicit
meaning.
Mini-world or the Universe of discourse (UoD) :
Represents some aspects /parts of the real world about which
data is stored in a database. For example, student registration
system at a university, Patients record system in a hospital.
Database Management System (DBMS):
A collection of programs/software package to facilitate the
creation and maintenance of a database.
Its facilitates the processes of defining, constructing,
manipulating, and sharing databases among various users and
applications.
Copyright © 2015 Ramez Elmasri and Shamkant B. Navathe
6
Typical DBMS Functionality
Define a particular database in terms of its data types,
structures, and constraints
Construct or Load the initial database contents on a
secondary storage medium
Manipulating the database:
Retrieval: Querying, generating reports
Modification: Insertions, deletions and updates to its content
Generating reports from the data
Processing and Sharing a database allows multiple users
and programs to access the database simultaneously
only.
Application Development Environments and CASE
ENTITY TYPE
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
E1 R E2 TOTAL PARTICIPATION OF E2 IN R
N
E1 R E2 CARDINALITY RATIO 1:N FOR E1:E2 IN R
Address
Figure 3.7
The CAR entity
type with two key
attributes
(a) (b)
Copyright © 2015 Ramez Elmasri and Shamkant B. Navathe
60
Relationship Types, Relationship Sets,
Roles, and Structural Constraints
Relationships of the same type are grouped or typed into a
relationship type.
For each STUDENT, the university maintains student Name, student ID, SSN (Social
Security Number), Address, Phone, Birthdate, Gender, Level, Major (CS, IS, CNET).
Both Social Security Number and Student Number have unique values for each
student.
Each COURSE has a Course Name, Description, Course Code, Credit Hours, Level,
and Offering Department. The value of Course Code is unique for each course.
Each EMPLOYEE has a SSN, Name, Sex, Department, Address, and Salary. The
value of SSN is unique for each employee, whereas Name, a composite attribute has
Fname, Minit and Lname as a subpart of it.
For each USER, the portal maintains user ID, Name, E-mail. Each user has
a unique ID. Name is a composite attributes with Fname, Midname, Lname.
Each LECTUR has a lecturer Title ID, Duration, and Date. The value of ID
is unique for each lecturer.
1. Key constraints
Unary
SELECT, operations
PROJECT UNION,
INTERSECTION,
SET DIFFERENCE, and
CARTESIAN PRODUCT
JOIN Binary operations
OR CROSS PRODUCT
(The <condition> must involve only columns from the mentioned table)
Eg: Select the tuples for all employees who either work in department 4 and
make over $25,000 per year, or work in department 5 and make over
$40,000, we can specify the following SELECT operation:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 41000 888665555 5
Jennifer S Wallace 987654321 1941-06-20 291 Berry, Bellaire, TX F 43000 888665555 4
Ramesh K Narayan 666884444 1962-09-15 975 Fire Oak, Humble, TX M 38000 333445555 5
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 41000 888665555 5
Jennifer S Wallace 987654321 1941-06-20 291 Berry, Bellaire, TX F 43000 888665555 4
πSex, Salary(EMPLOYEE)
R1 R2 R1 R2
a a
1 1
b b
2 2
c c
R1 X R2 R2 X R1
Copyright © 2015 Ramez Elmasri and Shamkant B. Navathe
118
CARTESIAN PRODUCT Operation
STUDENT X MAJOR
STUDENT MAJOR
SID SNAME GPA SID MAJOR
SID SNAME GPA SID MAJOR
10 ALI 3.5 10 CS
10 ALI 3.5 10 CS
10 ALI 3.5 11 IS
11 ZOYA 3.7 11 IS
10 ALI 3.5 12 CNET
12 ALEX 4.1 12 CNET
11 ZOYA 3.7 10 CS
11 ZOYA 3.7 11 IS
11 ZOYA 3.7 12 CNET
12 ALEX 4.1 10 CS
12 ALEX 4.1 11 IS
12 ALEX 4.1 12 CNET
9. Use above relation EMPLOYEE and write the relational algebra query.
a. Retrieve the records form EMPLOYEE whose department is 4.
b. Select the tuples where salary > 40000.
c. Retrieve the records of all employee who are Male and work for department
number 5.
10. Use above relation EMPLOYEE and write the relational algebra query.
a. List each employee’s First name, Last name and salary.
b. List First name, Last name and salary of all employees who work in
department number 5.
FDs and keys are used to define normal forms for relations
FDs are constraints that are derived from the meaning and
interrelationships of the data attributes
STUDENT
DEPARTMENT
ID Name Department
Dept_ID Head Phone
1001 S1 IS
IS Mr. A 0888888
1002 S2 CS
CNET Mr. C 0777777
1003 S3 IS
CS Mr. B 0999999
1004 S4 CNET
1005 S5 IS Redundancy Reduced
Copyright © 2015 Ramez Elmasri and Shamkant B. Navathe
140
Normal Forms
Types and Processes
EMPLOYEE
EMPLOYEE
Ssn Ename Address Salary Dept
1001 Ahmad, A, Jarebi Jazan 5600 IT
1002 Ali, Mohemmed, Hakami Sabya 7900 IS
1003 Yahya, M.,Makki Jeddah 8000 CS
1004 Mosa, A, Hazmi Abha 6700 IBD
EMPLOYEE
Ssn Fname Mnit Lname Address Salary Dept
1001 Ahmad, A., Jarebi Jazan 5600 IT
1002 Ali, Mohemmed, Hakami Sabya 7900 IS
1003 Yahya, M, Makki Jeddah 8000 CS
1004 Mosa, A, Hazmi Abha 6700 IBD
Multivalued
Attribute
Converted
in 1NF
Converted
in 1NF
2 Normal Form
FD1 FD3
P_ID Pname Description Order_ID Unit Total_Price
FD2
2 NF Normalization PROD1
P_ID Pname Description
FD1 : P_ID -> {Pname, Description}
PROD2
FD2: {P_ID,Order_ID } ->Total_Price P_ID Order_ID Total_Price
PROD3
FD3: Order_ID -> Unit Order_ID Unit
Examples:
- SSN -> DMGRSSN is a transitive FD since
SSN -> DNUMBER and DNUMBER -> DMGRSSN hold