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

Lecture 5 & 6 - Database Design

Uploaded by

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

Lecture 5 & 6 - Database Design

Uploaded by

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

Lecture 5 & 6

Database Design
Motivation - Why Model?

Understand/
Model Comprehend Control

Analysis &
Presentation
Conceptualization
Why Design & Organize?
• DATA
Unorganized form
Eg. student’s Score
• INFORMATION
processed, structured and
organized data
Eg. class average which can be
calculated from data.
Phases of Database Design

Logical
• ER Diagram Design • Tablespaces
• UML • Tables • Indexes

• Columns
Conceptual Physical
Design Design
Why ER Diagrams?
• Giving you image of how the tables should connect.

• What fields are going to be on each table.

• The tables connection, if many-to many, one-to-


many.

“ER diagrams are easy for non-technical

people to understand, and thus are

typically used by database designers

before the schema ever exists”


Example COMPANY Database

• The company is organized into DEPARTMENTs. Each department


has a name, number and an employee who manages the
department. We keep track of the start date of the department
manager.

• Each department controls a number of PROJECTs. Each project


has a name, number and is located at a single location.
Example COMPANY Database (Cont.)

• We store each EMPLOYEE’s social security number, address, salary, sex,


and birthdate. Each employee works for one department but may work on
several projects. We keep track of the number of hours per week that an
employee currently works on each project. We also keep track of the direct
supervisor of each employee.

• Each employee may have a number of DEPENDENTs. For each dependent,


we keep track of their name, sex, birthdate, and relationship to employee.
Entity

• An entity is something that exists by itself.

• Entity: Real-world object distinguishable from other


objects.

• An entity is described using a set of attributes.

EMPLOYEE PROJECT
ER Diagram Symbols and Notations
Examples of Entities

• Person: EMPLOYEE, STUDENT, PATIENT

• Place: STORE, WAREHOUSE

• Object: MACHINE, PRODUCT, CAR

• Event: SALE,REGISTRATION, RENEWAL

• Concept: ACCOUNT, COURSE


Entity Set
• Entity Set: A collection of similar entities.

Eg. all employees

• All entities in an entity set have the same set of attributes.

• Each entity set has a key.

• Each attribute has a domain.


Attributes
 Attributes are properties used to describe an entity.
 Example: EMPLOYEE entity may have a Name, SSN, Address,
Sex, BirthDate
Attribute Types
Attribute Types

Simple Composite Single-valued Multi-valued Derived

Ssn Address Gender Contact No. Age


Entity Types and Key Attributes

• An attribute of an entity type for which each entity must have a

unique value is called a key attribute of the entity type.


Ssn

• A key attribute may be composite.


Registration

Number State
Key Attributes (Cont.)

An entity type
may have
more than
one key.
Nested Composite Attribute
Types of Attributes - Notation
Example – Different Attributes
Key
Attribute

Composite Multi-valued
Attribute Attribute

Age
Simple Derived
Attribute Attribute
Relationship

• A relationship relates two or more distinct entities with a


specific meaning.

• Relationships of the same type are grouped or typed into a


relationship type.
EMPLOYEE WORKS_ON PROJECT

EMPLOYEE MANAGES DEPARTMENT


Relationship Example
Relationships and Relationship
Types
More than one relationship type can exist with the same
participating entity types.

EMPLOYEE WORKS_FOR DEPARTMENT

MANAGES
Degree of Relationship

Degree
(number of entity types that participate in a relationship)

Unary Binary Ternary


Degree of Relationship
Example
Attributes of Relationship Types

A relationship type can have attributes; for example, HoursPerWeek of


WORKS_ON; its value for each relationship instance describes the
number of hours per week that an EMPLOYEE works on a PROJECT.
Recursive Relationship
 An relationship with the same participating entity type in distinct
roles.

 Example: the SUPERVISION relationship

 EMPLOYEE participates twice in two distinct roles:

 supervisor (or boss) role

 supervisee (or subordinate) role


Roles

The function that an entity plays in a relationship is called


its role (optional). specify how employee
entities interact via the
works_for relationship set
Structural Constraints – Semantics
of Relationships

Cardinality Ratio (of a binary relationship): number of instance of


an entity from a relation that can be associated with the relation.
1:1 (One-to-One) Relationship -
Manages
N:1 (Many-to-One) Relationship –
Works_for
M:N (Many-to-Many) Relationship
– Works_on
Thanks!!

You might also like