You are on page 1of 78

" "

:

) (
) (DB systems
)(Database Management System DBMS

1.1

: : ) (......

.


.
-

.
( )
.





: -1 :
.
-2 :
.
-3 .
-4 .

-5 .
-6 .
-7 .
-8 .

.
2.1 )(File Systems

:

.
:
)
( . )
.......... ( .


) (


.

-:
-:

.
: ) (
.
:

.

:

.
:

: .
.
:
.
:
.

: .
:
.
: .
.

.
.
.

3.1



.
:
( ....)
: .


.
.
.
.


)(DBMS :

MS-Access
Oracle
MS-Sql
Sybase
Power Builder
Informix

(Self-Description Nature):

)(Meta-data

(Program/Data Insulation):

.

(Data Sharing and Multi-user


system):



4.1 )(Database Management System DBMS


: .
.
+
) + (
))(Database (DB) + DBMS Database System (DBS

: :
.1:




.

.2:

BACK UP .

.3) (:

DBMS

) .(1-10
.4 :
:
.
.
.
(DBA):
.
(DB Designer):
.

(End User):

.

(Analyst & Programmer):


. ) + (
)( Analyst + Programmer Software Engineer

:
).(ms-access
:

.
:

.

"

Architecture of DBMS

:


)(DB System
)(Data Independence

.2.1 :
.
Hierarchical DBMS
Network DBMS
Relational DBMS
Hierarchical DBMS : Hierarchical DBMS
.
.





.
.
.
. Set
.
.
IMS IBM
DBMS .


.
Network DBMS :

Plex .


) (4
) (2 (3) .

)(

)(

.
) (


.



.
Relational DBMS .
.

.
:
1. .
2. .
3. .
1970 E.E.Codd .
.
E.E.Codd
.

Relation Fields
Attributes Tuples
Relation .

SQL . ORACLE PCs
DBaseII . DBaseIII . DBaseIII+ . DBaseIV . FoxBase . FoxPro .


Flat File .


Relational Data Submodel or View
Subschema View .

) )

.


Implicit Relationships
Explicit Relationships .

] [
] [ . ] ] ]
[
.

. :


)(
: makkah 1433

)(000110111... Unicod.
)(
.




:
( (
) ( .
:
5 :
:
(Boolean): false or true
:

:integer 2
32764- . 32764+
:long 4
:Float 4.
: double 8.
:

makkah1433@uqu.edu.sa

: char
:string
enumerations .
Enum
Nissan Toyota FIAT 1 0 2

.
:

:date .
3.2 ): (DBMS Architecture
. ( Centralized system) :

.
. (Client-Server):
( )
(
)

)(Instances
)(DB State or Current Set of Occurrence or Instance


) (
Extension

4.2 )(DB System


:
. )(The External or View Level
. )(The Conceptual Level
. )(Internal Level

. The External or View Level:




. :The Conceptual Level
Conceptual Schema
-

Conceptual data model Representation data model


3. (Internal Level):
.
)(Physical Data Model .
):(The Three-Schema Architecture

5.2 )(Data Independence

)(mapping

:
o )(Logical Data Independence
o )(Physical Data Independence

(Logical Data Independence):

)(Conceptual Level
)(External Level

(Physical Data Independence):


))Internal Level
)(Conceptual Level
)(Internal Level

6.2

(Data Definition Language DDL):

)(DBA )(DDL Compiler (DB Catalog).

(View Definition Language VDL):


)(External Level Forms GUI
menu

( Data Manipulation Language DML):

DDL,VDL,DML )(SQL DDL,VDL,DML




:

(DDL Compiler):

(Run-Time DB processor):

(Query Compiler):

(Loading):

(Backup):

(File reorganization):

(Performance monitoring):

)(DBA
( )

( CASE tools ):

"

:

UDA

1.3

ADO ActiveX Data Objects


Access Oracle SQL
Server ..
ADO DAO ODBC ... ...

:

SQL Server / FoxPro Database / Oracle DB / ...


APIs .
APIs
APIs
SQL Server DB APIs
Oracle OCI APIs .
API
Application Programming Interface )
(
API )(
.
!!!
c
>#include <iostream
>#include <stdlib.h
iostream API

.

3
FoxPro SQL Server Oracle

...

..

Universal
Database
SQL Server ..


..
UDA
Universal Data Access


.

Resized to 90% (was 678 x 650) - Click image to enlarge

2.3UDA
1992 ODBC
Open DataBase Connectivity UDA

DAO Data Access Object
ADO
ActiveX Database Object
:

ADO.Net
ADO ADO.Net
..

"

Relational Databases



)Relationships (

1.4
))(Relational Database Management System (RDMS
.
.
: ) (

)(Database Model .
.
) (
:-o
o

2.4
Data : Metadata : Data about data

/
(high-level conceptual data model)
)(Conceptual Model

database schema
.
Entity : ( )
.
. : . Relationships:
.




.
.
.

.
):(Attribute ERD
.


derived attribute



derived


Composite
Attribute


Multivalve
Attribute

Simple
Attribute

) (

) (
) (

Data Item:

1000
1000 .

Data aggregate :

( )
.
.

Record :

. :
o
o

) (
:
) 1000 (
) 2500 (

3.4Relationships
(Relation): ) ( R )(E1,E2, ...En
)(R
.

):(Degree of Relationship
) ( - ...
.

. (Cardinality Ratio):

. )(Instances
:

. -- ):(one-to-one
1:1
. -- ): (one-to-many
1:N
. -- ): (many-to-many

M:N

Relationship Constraints:


.
1. (Total participation):

( )

.

.

2. (Partial participation):

.

Key :

( )
:-

Primary Key:
)(Unique

.

Foreign Key:
.

Secondary Key:

(Weak Entity) :

) :(Partial key

) (
11
7
9

12
15
14

"
EER
))(Enhanced Entity Relationship (EER-MODEL

:
EER
):(Generalization
):(Generalization
)(Constraints

(5.1 EER
ER
) (Super class ) ( Subclass
).(Inheritance


.
.
:




.
.
: ) (
:

: . . : . . . : . .
.....
.
. .




)
(
.
) (
.

(2.5 ):(Generalization


.... //
: .
.
.
. .

:
)( . ISA
.

ISA

ISA


ISA ) (

(3.5 ):(Generalization

Super class .Sub classes
:

(4.5 ):(Constraints
//
.1 :
:
) . ( job type
. " "
secretary .................
" " .

. ) : (Competence Constraints
:

:
.

: .

.

""

""

. :

.
:


.
.
. ) (disjoint )(overlapping

.
.

d .

: .
.
:

(5.5 :

:
-1 :

Equipment
number

description

Acquisition
date
Purchase
cost

EQUIPMENT

- :

License
number

name

street

city
state

telephone

FISHING-LICENSE

name

Vessel
number

numberyears
atthisaddress

type
COMMERCIAL-LICENSE

SPORT-LICENSE

prioryearlicen
senumber

taxid

NAME
ZIP

ADDRESS

SALESPERSON
NAME

PHONE
STATE

SALES PERSON

CUSTOMER

SALESPERS
ONCODE

CITY
DATE

HAS

HAS

SALESORD
ERNUMBER

SALES-ORDER

SUBTOTAL

TAX
TOTAL
CONTAIN

ITEM
NUMBER

LINE
NUMBER
ORDER-LINE-ITEM

HAS

ITEM

QUANTITY

UNIT PRICE

UNIT PRICE

DESCRIPTION

EXTENDED
PRICE

Associatetive entity
Binary relationship
cardinality
Database object
Data diagram
Data model
Identifier
Many-to-Many binary relationship
One-to-Many binary relationship
One-to-One binary relationship

--
--
--

Primary key
Referential integrity
Ternary relationship
Unary relationship
competence constraints
recursive relationship
super class
subclass
inheritance
Entity type
Strong entity
Weak entity
specialization
generalization
Conceptual model
Logical model
Physical model



Design of Relational Database

:
)Database Life Cycle (DBLC

) (Mapping Algorithm

)1 (

) 2 (

) (Normalization

(1.6 )Database Life Cycle (DBLC



,


.
.
.
).(E-RD
:
. /
.
. Normalization
.

:physical database
SQL
DBMS oracle,
))Access, sqlserver, MySQL . etc.

Database Schema

DBMS Mapping
Algorithm

(2.6
Mapping ERD to DB schema
ERD Mapping
Algorithm

(Mapping Algorithm):

)(

1:1
1:N
N:M

:
.
)primary key(PK
.
:

PK
FK )(Partial Key .
(1:1): --


(
)
(1:N):

)(N ( .
(N:M):


.
. :
FK
.


. :
( )
( ((N:M

.

: 1 Database

( )
:
)(Student
)(Instructor
)(Course


( )( ).

) ( .
) ( .
) (
.

)(Primary Key
:
name
program

title

Cre

dept

sylla

sid

name

title

STUDENT

iid

cours

INSTRUC

COU

2. :

:
)(Course-Offerings

:
)(Year )(Semester )(Section-no )
( .


.
.
:

)(Course-Offerings )(Course
)(Foreign Key )(courseno

()
:

:

)(One-to-One Relationship
)(One-to-Many
)(Many-to-Many

( )
:
--


( ).
.
- -
:

.
.
)(teaches )(Instructor
)(Course-Offerings

)(teaches )(Instructor
(Course-Offerings).

)(iid Instructor
course-offerings Course-Offerings
:

)(Course-Offerings )(Instructor
)(iid

:



:

)(enrols

ENROLS

sid

courseno

secno

:
year
semester
grade

(Requires) 2)

:
maincourseno
prerequisiteno

REQUIRES

)(Requires )(course

) (1
:

:2

)(Employee
)(Department
)(Project

. )(Employee
)(Name
) (Fname ) (Minit (Fname).

. )(Department
) (Number of employees

)(locations

.

) . (:

:
Proj
Number
Name
Location

. :
:
) (Dependent .

)(Name:
)(Employee
(Dependent_of).

)(Dependent
)(Employee
(Dependent-of).
)(Empoyee-Ssn (Dependent-Name).

)(Dependent )(Employee

(Employee-Ssn).

.3 :
.3 . :
- - )(Manages

) (start_date .

)(Employee_Ssn
) (start_date )(department
) (Manager
Employee_Ssn Manager_Ssn
)(Department :
Number
Name
Manager-Ssn
Start_date

Departm

)(Department )(Employee
(Employee-Ssn).

.3 . :
:
. )(Works_for

)(Employee
)(Department_Number )(Employee :

)(Controls

)(Project
)(Department_Number )(Project
:
Project
Number
Name
Location
Department_Number
)(Department-Number
:

(Supervision):

)(Supervisor

.
)(Employee :
.3 . :


)(Works_on

) (Works-on
)(Employee ) (Project )(Hours
:

)(Employee )(Project
)(Works_on )(Employee-Ssn
Employee )(Project-Number )(Project

) (2 :

.3 :Normalization rules
.

relations
)( .

.
.
?:Why Normalization
. ) ( .
) (data redundancy . .
: Normalization Advantages
:
.
). ( inconsistency . many-to-many . one-to-many . :
:
)( . . .
.Demoralization
: Demoralization
:Functional Dependencies
) two attributes( .
B A :
) A B B (A
student studentID
.

studentID :

..
:

.
:
A A=BC D :
AD D A C .D
D A B C D.
:
:
. . :
A B B C AC
AB .BC
:Normal Forms
) relation(
.


:

)1st Normal Form (1NF

)2nd Normal Form(2NF

)3rd Normal Form(3NF

)Boyce-Codd Normal Form(BCNF

)4th Normal Form(4NF

)5th Normal Form(5NF


- :(1NF) first normal form
) (

Atomic .
- :(2NF) second normal form
) ( :
( )( .

( .
- :(3NF) third normal form
) ( :
( .
( .
:
:
- BCNF .



.
:


.

( :1NF
.0NF

.
children gender EMP 0NF Nun_children .

EMP 1NF .

- EMP:

EMP .1NF( :2NF


.1NF
. . .
- .


cust_ID ) stock (.
:
- Cust_ID Name,Addr
)(Partial FD
) ( ) ( ........ .
- Stock Curr_price,Dividend
)(Partial FD
) ( )( ... .
)(full FD

Cust_ID,Stock Shares

.. .

.

- :

relations .2NF( :3NF


. .
) ( .
.

) ( .

- :

)( Mfr
.

:
normalization 0NF
3NF .CDs


.
Receipt
.
Date
.
PID
.
Pname
.
Phone

City

State
.
VID
.
Vname
.
Type
.
Days
.
Cost


DDL: Data Definition Language)
(DML: Data Manipulation Language
MS-SQL SERVER2000
:
PDF
Integrity Enhancement Feature
create statement
Alter Statement
Select Statement
Where Statement
Insert Statement
Update Statement
Delete Statement
Order By
And or between
Alias
Function

You might also like