0% found this document useful (0 votes)
8 views40 pages

Mod 1 3

Uploaded by

Risha Lekhwani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views40 pages

Mod 1 3

Uploaded by

Risha Lekhwani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

MODULE 1

Chapter 3
Data Model

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley


Chapter 3 Outline
▪ Main Phases of a Database Design Process
▪ Entity Types, Entity Sets, Attributes, and Keys
▪ Relationship Types, Relationship Sets, Roles, and
Structural Constraints
▪ ER Diagram Notations and examples

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Using High-Level Conceptual Data
Models for Database Design

▪ Requirements collection and analysis


▪ Database designers interview prospective database users
to understand and document data requirements
▪ Result: data requirements
▪ Functional requirements of the application

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Using High-Level Conceptual Data Models (cont’d.)

▪ Conceptual schema
▪ Conceptual design
▪ Description of data requirements
▪ Includes detailed descriptions of the entity types, relationships,
and constraints
▪ Transformed from high-level data model into implementation
data model

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Using High-Level Conceptual Data Models (cont’d.)

▪ Logical design or data model mapping


▪ Result is a database schema in implementation data model of
DBMS
▪ Physical design phase
▪ Internal storage structures, file organizations, indexes, access
paths, and physical design parameters for the database files
specified

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
A Sample Database Application

▪ COMPANY
▪ Employees, departments, and projects
▪ Company is organized into departments
▪ Department controls a number of projects
▪ Employee: store each employee’s name, Social Security
number, address, salary, sex (gender), and birth date
▪ Keep track of the dependents of each employee

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Chapter 3 Outline
▪ Main Phases of a Database Design Process
▪ Entity Types, Entity Sets, Attributes, and Keys
▪ Relationship Types, Relationship Sets, Roles, and
Structural Constraints
▪ ER Diagram Notations and examples

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Entity Types, Entity Sets, Attributes, and Keys

▪ ER model describes data as:


▪ Entities
▪ Relationships
▪ Attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Entities and Attributes
▪ Entity
▪ Thing in real world with independent existence
▪ Attributes
▪ Particular properties that describe entity
▪ Types of attributes:
• Composite versus simple (atomic) attributes
• Single-valued versus multivalued attributes
• Stored versus derived attributes
• NULL values
• Complex attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Composite versus simple (atomic) attributes
• Composite attributes can be divided into smaller subparts, which
represent more basic attributes with independent meanings.
• Attributes that are not divisible are called simple or atomic attributes.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Single-Valued versus Multivalued Attributes.
• Most attributes have a single value for a particular entity;
such attributes are called single-valued.
Ex: Age is a single-valued attribute of a person.

• In some cases an attribute can have a set of values for the


same entity, Such attributes are called multivalued
Ex: Colors attribute for a car, or a College_degrees
attribute for a person.
• Multivalued attributes are represented with double oval
symbol.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Stored versus Derived Attributes.
• In some cases, two (or more) attribute values are related to each other.
• Stored attribute is an attribute which are physically stored in the
database.
• Assume a table called as student. There are attributes such as student_id,
name, roll_no, course_Id. We cannot derive value of these attribute using
other attributes. So, these attributes are called as stored attribute.

• A derived attribute is an attribute whose values are calculated from


other attributes.
• In a student table if we have an attribute called as date_of_birth and age.
We can derive value of age with the help of date_of_birth attribute.
• Stored attribute is represented by an oval.
• Derived attribute are represented by a dotted oval.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


NULL Values

• In some cases, a particular entity may not have an applicable value for an
attribute. For such situations, a special value called NULL is created.
• Ex: Apartment_number, College_Degree

Complex Attributes

• composite and multivalued attributes can be nested arbitrarily. Such


attributes are called complex attributes.
• Ex: {Address_phone({Phone(Area_code,Phone_number)},
Address(Street_address(Number,Street,Apartment_number),
City,State,Zip) )}

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Entity Types, Entity Sets, Keys and Value Sets
Entity Types and Entity Sets.

The collection of all entities of a particular entity type in the database at any point
in time is called an entity set or entity collection

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Key Attributes of an Entity Type

❑An important constraint on the entities of an entity type is the key or uniqueness
constraint on attributes.
❑An entity type usually has one or more attributes whose values are distinct for
each individual entity in the entity set.
❑Such an attribute is called a key attribute, and its values can be used to identify
each entity uniquely.
❑Ex: Company Name in Company entity type, SSN in Person entity type
❑Each key attribute has its name underlined inside the oval

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Key Attributes of an Entity Type
Some entity types have more than one key attribute.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Value Sets of Attributes
Each simple attribute of an entity type is associated with a value set (or domain
of values), which specifies the set of values that may be assigned to that
attribute for each individual entity.
range of ages allowed for
employees is between
16 and 70

Name attribute to be the


set of strings of alphabetic
characters separated by
blank characters

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Initial Conceptual Design of the COMPANY Database

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Chapter 3 Outline
▪ Main Phases of a Database Design Process
▪ Entity Types, Entity Sets, Attributes, and Keys
▪ Relationship Types, Relationship Sets, Roles,
and Structural Constraints
▪ ER Diagram Notations and examples

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


▪ Relationship
▪ When an attribute of one entity type refers to another entity type
▪ Represent references as relationships not attributes

▪ Ex: Department & Employee


▪ Project & Controlling Departments

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Relationship Types, Sets & Instances
A relationship type R among n entity types E1, E2, . . . , En defines a set of associations
or a relationship set—among entities from these entity types.
The relationship set R is a set of relationship instances ri, where each ri associates n individual entities (e1, e2, . .
. , en), and each entity ej in ri is a member of entity set Ej, 1 <= j <= n.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Relationship Degree, Role Names and Recursive Relationships
▪ Degree of a relationship type
▪ Number of participating entity types
▪ Binary, ternary
▪ Relationships as attributes
▪ Think of a binary relationship type in terms of attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Role Names and Recursive Relationships
▪ Role names
▪ Role name signifies role that a participating entity plays in each
relationship instance.
▪ It helps to explain what the relationship is

▪ Recursive (or self referencing) relation


▪ Same entity type participates more than once in a relationship
type in different roles
▪ Must specify role name

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Role Names and Recursive Relationships

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Constraints on Binary Relationship Types
▪ Cardinality ratio for a binary relationship
▪ Specifies maximum number of
relationship instances that entity can
participate in.
▪ 1:1, 1:N, N:1, M:N

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Constraints on Binary Relationship Types
Participation constraint
▪ Specifies whether existence of entity depends on its being related to another entity
▪ This constraint specifies the minimum number of relationship instances that each
entity can participate in and is sometimes called the minimum cardinality constraint
▪ Types: Total (Existence Dependancy) and Partial (Structural Constraint)
▪ Total: The participation of EMPLOYEE in WORKS_FOR is called total participation,
meaning that every entity in the total set of employee entities must be related to a
department entity via WORKS_FOR.
▪ Partial: we do not expect every employee to manage a department, so the
participation of EMPLOYEE in the MANAGES relationship type is partial, meaning
that some or part of the set of employee entities are related to some department
entity via MANAGES, but not necessarily all

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Constraints on Binary Relationship Types
Total Constraint (Existence Dependancy) Partial Constraint (Structural Constraint)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Attributes of Relationship Types
▪ Relationship types can also have attributes, similar to those of entity types.
▪ For example, to record the number of hours per week that a particular employee works on a
particular project, we can include an attribute Hours for the WORKS_ON relationship type.
▪ Another example is to include the date on which a manager started managing a department via
an attribute Start_date for the MANAGES relationship type

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Weak Entity Types
▪ All regular entities which do have keys are called strong entity
types.
▪ Entities which do not have key attributes of their own are called
Weak entity types.
▪ Identified by being related to specific entities from another
entity type
▪ Identifying relationship
▪ Relates a weak entity type to its owner
▪ Always has a total participation constraint.
▪ Has a Partial Key which is the attribute that can uniquely
identify weak entities that are related to the same owner entity
▪ Ex: Dependent entity type in Company database.
▪ Represented as double rectangle box.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Chapter 3 Outline
▪ Main Phases of a Database Design Process
▪ Entity Types, Entity Sets, Attributes, and Keys
▪ Relationship Types, Relationship Sets, Roles, and
Structural Constraints
▪ ER Diagram Notations and examples

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


ER Diagrams, Naming Conventions, and Design Issues

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Proper Naming of Schema Constructs
▪ Choose names that convey meanings attached to different
constructs in schema
▪ Nouns give rise to entity type names
▪ Verbs indicate names of relationship types
▪ Choose binary relationship names to make ER diagram
readable from left to right and from top to bottom

Copyright © 2011 Ramez Elmasri and Shamkant Navathe


Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Copyright © 2011 Ramez Elmasri and Shamkant Navathe
Question Bank
1. Explain different types of attributes that occur in an ER diagram with example.
2. Draw an ER diagram for an airline database schema with atleast five entities.
Also mention the primary key and structural constraints.
3. Draw an ER diagram for a company database with atleast four entities.
4. Explain recursive relationship types with examples.
5. Write a note on Participation constraints on binary relationship types.
6. Define the following terms
i) Cardinality
ii) Weak entity
iii) Program data Independence
iv) Total participation
v) Value Sets
Copyright © 2011 Ramez Elmasri and Shamkant Navathe

You might also like