0% found this document useful (0 votes)
11 views

3 Relational Database Model

This document discusses the mapping of an entity relationship model to a relational database model. It describes how entities, attributes, and relationships in an ER diagram map to tables, columns, and constraints in a relational schema. It also explains different types of constraints used in the relational model like domain constraints, key constraints, null constraints, and referential integrity constraints.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

3 Relational Database Model

This document discusses the mapping of an entity relationship model to a relational database model. It describes how entities, attributes, and relationships in an ER diagram map to tables, columns, and constraints in a relational schema. It also explains different types of constraints used in the relational model like domain constraints, key constraints, null constraints, and referential integrity constraints.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

EE4202 Database Systems

REPRESENTATIONAL DATABASE MODEL –


(RELATIONAL MODEL)
ER TO RELATIONAL MAPPING
Entity Relationship Model Relational Model • Domain is the set of all distinct values that can be
Entity type Relation/Table assigned for an attribute.
Attribute name Column header • Domain has a role name (attribute name), data type
Attributes Domain constraint, Null constraint and format. Data types of attributes can be any one of
Entity/Relationship instance Tuple/Row integer (Ex: 2,3), decimal (total, decimal places) (Ex:
5.89), varchar(size)/char(size) (Ex: “Kamal Fonseka”),
Relationship type Referential integrity constraint or
normalized into a separate table Boolean (Ex: 0, 1), date (20/11/2020), time (13:54:34)
etc.
Candidate Keys Key constraint, Entity Integrity
--------------------------------------- Data constraints • Null value can be assigned to an attribute if the
--- attribute is not applicable (Ex: Apartment num) or
value exists and missing (Ex: height) or unknown about
existence (Ex: degrees).
• A relational schema (intention/definition) is defined in SQL as,
CREATE TABLE Relation_name(
Attibute_1 data type default ‘def_val’,
Attribute_2 data type NOT NULL,………..,
Attribute_n data type,
PRIMARY KEY (Attribute_1, Attrbute2),
constraint fk1 foreign key (attribute1) references othertable(attr2) on delete set NULL on update set
DEFAULT);
CONSTRAINTS IN RELATIONAL MODEL
• Composite and multivalued attributes in ER-model cannot be implemented in Relational model. All attribute
values must be atomic, single valued (Domain constraint) and all tuples must be distinct (Entity Integrity)
which is relational model must be in first normal form.
• Normalization is the goodness of design of a relational database.
• Multivalued attribute must be shown as a separate relation.
• Composite attribute can be broken into atomic attributes.
• Schema based constraints are
 Domain constraints
 Key constraints
 Constraints on nulls
 Entity integrity constraints
 Referential integrity constraints
• Data constraints are
• Functional dependencies
• Multivalued dependencies
CONSTRAINTS

• Domain constraints – Each value of the attribute of the tuple must be atomic and single valued within its
domain.

• Key constraint - When there are candidate keys only one of them is declared as primary key and underlined
and other key attributes are declared with unique property.

• Constraints on null specifies whether null values are permitted or not.

• Entity integrity constraint specifies that primary key must be defined and the value cannot be null.
REFERENTIAL INTEGRITY
employer worker head 1
DEPARTMENT 1 WORKS N EMPLOYEE EMPLOYEE
_IN
SUPERVIS
ES
employee N
EMPLOYEE
Employee_ID Department Area Designation Field_Supervisor
EE001 EIE Software Lecturer NULL
1 MANA 1 EMPLOYEE
EE002 EIE Communication Senior Lecturer EE001 DEPARTMENT
GES
MM007 MME Automobile Lecturer NULL
DEPARTMENT
MM001 MME Manufacturing Senior Lecturer MM007 Dept_ID Head Location Accreditation
CE001 CEE Hydraulic Senior Lecturer NULL
ElE EE001 Sector B Yes
CE003 CEE Structural Lecturer CE001
MME MM007 Sector A Yes
CE007 CEE Environment Lecturer CE001
CEE CE001 Sector C Yes
EE005 EIE Electronics Lecturer EE001

• Referential integrity states that tuple from the referencing relation must refer to an existing tuple in the
referenced relation or be null.
• The referencing attribute is called foreign key and it refers to a primary key in other relation.
• This facilitates to maintain the concept of relationships in ER model.
• Indicated using a dashed arrow from foreign key to the primary key.

You might also like