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

DBMS PPT7

This document discusses database design and the process of converting an entity-relationship (ER) model into relational tables. It explains that logical design involves gathering requirements and creating a model, while physical design converts the logical model into database tables. Each entity in an ER model becomes a table, attributes become fields, and the primary key is given by the entity's identifiers. Different types of relationships like one-to-one, one-to-many, many-to-many are discussed. The document also provides instructions for a term project on designing a database.
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)
34 views

DBMS PPT7

This document discusses database design and the process of converting an entity-relationship (ER) model into relational tables. It explains that logical design involves gathering requirements and creating a model, while physical design converts the logical model into database tables. Each entity in an ER model becomes a table, attributes become fields, and the primary key is given by the entity's identifiers. Different types of relationships like one-to-one, one-to-many, many-to-many are discussed. The document also provides instructions for a term project on designing a database.
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/ 23

Database Management Systems

Database Design (2)

1 Database Management Systems, Roya Choupani 5/18/2020


Topics
 Data Base Design
 Logical Design (Review)
 Physical Design
 Entity Relationship (ER) Model to Relational Model
 Entity
 Relationship
 Attributes

2 Database Management Systems, Roya Choupani 5/18/2020


Database Design
 Database design is the process of producing a detailed data
model of a database.
 Database design includes:
 Determining data to be stored
 Determining main entities and their attributes
 Determining relationships between entities
 Designing a suitable model to store them

3 Database Management Systems, Roya Choupani 5/18/2020


Logical and Physical Design
 Logical design is about gathering requirements and converting
those requirements into a model.
 Physical design is the process of converting the logical model into
database tables.

4 Database Management Systems, Roya Choupani 5/18/2020


Converting E-R Model into Relational
Model
 Each entity in an E-R model is converted to a table in
relational model.
 The attributes of the entity become fields of the table
 Primary key is given by the identifiers of the entity

5 Database Management Systems, Roya Choupani 5/18/2020


Sample E-R Model

6 Database Management Systems, Roya Choupani 5/18/2020


Example
CREATE Table Employee
(
Code Integer PRIMARY KEY,
Surname Char(30),
Salary Integer,
Age Integer
)

7 Database Management Systems, Roya Choupani 5/18/2020


One-to-One Relationships
 One-to-one relationships are defined as attributes.
 e.g. Book  ISBN : Each book has only one ISBN and each
ISBN represents only one book. ISBN should be an attribute
for book.

 For restricting access to sensitive data, some attributes can be


stored in a second table.
 User and Password have a one-to-one relationship. Password
should be an attribute for the user but we generally create a
new table as <UsrID,Password>

8 Database Management Systems, Roya Choupani 5/18/2020


One-to-Many Relationships (1)
 One-to-many relationships are defined as foreign keys.
 e.g. An employee is a member of one department
A department has many members
In employee table define attribute dept to show the department
of each employee. dept is a foreign key referring to
Department.

9 Database Management Systems, Roya Choupani 5/18/2020


One-to-Many Relationships (2)
 If relation has attributes then we have to define it as a table.
 e.g. The relationship Membership between Employee and
Department has “start date” attribute.
 The relationship which is defined as a table can store the history of a
relationship.
 The primary keys of both entities and the attributes of the
relationship are added to the table

10 Database Management Systems, Roya Choupani 5/18/2020


Example
Create Table Membership
( EmpCode Number references Employee(code),
DeptName char(20) references
department(name),
startDate date,
position char(30),
PRIMAR KEY ( EmpCode, DeptName, startDate)
)

11 Database Management Systems, Roya Choupani 5/18/2020


Many-to-Many Relationships
 All many to many relationships are defined as tables.
 e.g. Student  Course
 A student takes many courses and a course is taken by many
students
 The primary key of both entities are added to the table
 <StudentID, CourseCode,Year-Semester, Grade>

12 Database Management Systems, Roya Choupani 5/18/2020


Recursive Relationships
 Recursive relationships are defined as a foreign key attribute.
 e.g.
Human < ID, Name, Surname, Birth Date, Sex, Father >
Father is a foreign key to table Human (recursive)

13 Database Management Systems, Roya Choupani 5/18/2020


Ternary Relationships
 Ternary relationships are defined as a table.

 The primary key of three tables are included in the table

 e.g. A client borrows a book from a library


entities are: Client, Book, Library
Borrow < BookID, ClientID, LibID, Date,..>

14 Database Management Systems, Roya Choupani 5/18/2020


Composite Attributes
 Composite attributes are defined as a table
 The primary key of the composite attribute table is added to
the table using it as foreign key.
 e.g. Address<Street, HouseNumber, PostCode>
PostCode is primary key
 Person <Surname, Age, Sex, PostCode >
PostCode is foreign key

15 Database Management Systems, Roya Choupani 5/18/2020


Summary
 Database design is the process of modeling data in an
information system.
 E-R model is converted into relational tables in physical
design.
 Entities and many-to-many relationships, and one-to-many
relationships with attribute in E-R model are converted to
tables.

16 Database Management Systems, Roya Choupani 5/18/2020


Questions?

17 Database Management Systems, Roya Choupani 5/18/2020


Term Projects
 Follow the following steps in your term project:
 Choose your teammate (groups of two at most)
 Choose a title, e.g. Library Database
 Send your team members, project title by email to me.

18 Database Management Systems, Roya Choupani 5/18/2020


Term Projects
 Create a list of data items that will be stored in your
project. For example, in library project, you may ask the
library. Items need not be put in any order.
 Find and list all entities.
 Find the attributes of entities (the attributes are data
items that you already found)
 Define restrictions for each attribute (e.g. Number of
digits in student ID, range of values for Age attribute, …)

19 Database Management Systems, Roya Choupani 5/18/2020


Term Projects
 Define relationships between entities and their types (Explain
how you found the type of the relationships)
 Create Entity-Relationship (ER) model of your database.
 Create necessary tables for your database.
 Show in which normal forms your tables are.

20 Database Management Systems, Roya Choupani 5/18/2020


Term Projects
 Design necessary queries based on the requirements of the
project
 Write necessary SQL commands to create tables and queries
 Write a report for your project (put all steps explained
above)
 Implement your project using a DBMS (Oracle, MS-SQL,
MySQL, MS-Access, … )

21 Database Management Systems, Roya Choupani 5/18/2020


Term Projects
Evaluation
 Gathering data items (10)
 Defining entities, the attributes of the entities, the
restrictions on the attributes (15)
 Relationships (10)
 ER model (10)
 Queries (15)
 Implementation (15)
 Report (10)
 Presentation (15) (is necessary)
22 Database Management Systems, Roya Choupani 5/18/2020
Presentations
 Will be during the last week of the semester starting from
June 15th
 The presentation schedule is posted on the webpage of the
course.

Database Management Systems, Roya


23 Choupani 5/18/2020

You might also like