Escolar Documentos
Profissional Documentos
Cultura Documentos
• Relation consists of
• Relation schema
• Relation instance (table)
• Specified : When the DBA /end user defines the data base schema
• Enforced : When database application is run
• DBMS checks for violations
• Disallow violating entries
11
• Domain constraints
• Key constraints
• Entity integrity constraints
• Referential integrity constraints
12
• Restricts the :
• Type
• Values that can appear in the field
Eg. • Name Char (25)
• GPA (real >=0, =<4)
13
FK
cid grade stuid PK Student s
Carnatic101 C 53666
sid name login age gpa
Reggae203 B 53666
53666 Jones jones@cs 18 3.4
Topology112 A 53650
53688 Smith smith@eecs 18 3.2
History105 B 53666
53650 Smith smith@math 19 3.8
Enrolled
19
ESOFT COMPUTER STUDIES - GALLE DB1
Students sid name login age gpa
• For example,
ARTIST
name 27
Primary key
ESOFT COMPUTER STUDIES - GALLE DB1
Mapping: Composite Attribute
ER Model Relational Model
• Composite attributes Set of simple
attributes atomic
EMPLOYEE
fullname firstname
28
surname
ESOFT COMPUTER STUDIES - GALLE DB1
Mapping: Multivalued Attributes
ER Model Relational Model
• Multivalued attribute Relation & Foreign Key
ART-OBJECT
Art -Object
type id type
id
materials MATERIALS
material id
29
B
A R
B b a
a
b 30
AB
A has B
31
N S-DEGREE
Student
S-DOB 32
S-ID S-NAME
ESOFT COMPUTER STUDIES - GALLE DB1
Mapping : M:N Conversion
FK
FK
B
A
pkB
pkA
A B
R pkA pkB pkC pkD
r
C D
34
C D
pkC pkD
ESOFT COMPUTER STUDIES - GALLE DB1
Mapping Weak Entities … (contd.)
ER Model Relational Model
Weak Entity Relations and
combination of partial and primary keys
1
Employee EMPLOYEE
Policy id
id
N
Dependents DEPENDENTS
35
id name age
name age
ESOFT COMPUTER STUDIES - GALLE DB1
Mapping ISA Relationship
36
39
TECHNICIAN
SSN FName MInit LName Birth Address Job TGrade
Date Type
ENGINEER
SSN FName MInit LName Birt Address Job EngType
h Type
Date
41
43
45
ESOFT COMPUTER STUDIES - GALLE DB1
Mapping - Summary
ER Model Relational Model
Entity (strong) -> Relation
Simple Attributes -> Attributes
Primary Key -> Primary Key
Composite attributes -> Set of
attributes simple
1:1 or 1:N relationship -> Foreign keys
M:N relationship -> Relation and foreign
keys
Multivalued attribute -> Relation and foreign
key
N-ary relationship -> Relation and n foreign
keys
Weak Entity -> Relation and combination of primary and partial
keys
46
48