0% found this document useful (0 votes)
36 views67 pages

Chapter 3

The document discusses database design and provides details on the three levels of database design: conceptual, logical, and physical. It defines key concepts like entities, attributes, relationships, and ER modeling. The conceptual design focuses on identifying entities, attributes, relationships, and constraints through techniques like interviews and documentation review. The logical design involves normalization. The physical design specifies storage structures and access methods tailored to a specific DBMS. Overall, the document provides an overview of database design principles and concepts.

Uploaded by

Jonathan T
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)
36 views67 pages

Chapter 3

The document discusses database design and provides details on the three levels of database design: conceptual, logical, and physical. It defines key concepts like entities, attributes, relationships, and ER modeling. The conceptual design focuses on identifying entities, attributes, relationships, and constraints through techniques like interviews and documentation review. The logical design involves normalization. The physical design specifies storage structures and access methods tailored to a specific DBMS. Overall, the document provides an overview of database design principles and concepts.

Uploaded by

Jonathan T
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/ 67

Database Design 6/24/2023

HiLCoE School of Computer Science & Technology


Chapter Three: Database Design

Course Title : Database Management Systems


Instructor name: Yitayew Solomon
E-mail address: [email protected]
Outlines of Discussion 2

@ What is Database Design?

@ The Three levels of Database Design

@ Entity and Attributes

@ The Entity Relationship (E-R) Model

@ Types of relationship in ER model

@ Converting ER Diagram to Relational Tables


What is Database Design?
• Database design is the process of coming up with different kinds of specification
for the data to be stored in the database.
• The database design part is one of the middle phases we have in information
systems development where the system uses a database approach.
• Design is the part on which we would be engaged to describe how the data should
be perceived at different levels and finally how it is going to be stored in a
computer system.
• Information System with Database application consists of several tasks which
include:

6/24/2023 Database Design 3


Cont. …

✓Planning of Information systems Design

✓ Requirements Analysis,

✓ Design (Conceptual, Logical and Physical Design)

✓ Implementation

✓ Testing and deployment

✓ Operation and Support


6/24/2023 Database Design 4
Cont. …
• From these different phases, the prime interest of a database system
will be the Design part which is again sub divided into other three
sub-phases. These sub-phases are:

1. Conceptual Design

2. Logical Design, and

3. Physical Design

6/24/2023 Database Design 5


Cont. …
• In developing a good design, one should answer such questions as:

✓ What are the relevant Entities for the Organization.

✓ What are the important features of each Entity.

✓ What are the important Relationships among Entities.

✓What are the important queries from the user.

✓ What are the other requirements of the Organization and the Users.

6/24/2023 Database Design 6


The Three levels of Database Design

6/24/2023 Database Design 7


Conceptual Database Design
• Conceptual design is the process of constructing a model of an
information used in an enterprise, independent of any physical
considerations.

• It is the source of information for the logical design phase.

• Mostly uses an Entity Relationship Model to describe the data at this


level.

• After the completion of Conceptual Design one has to go for refinement of


the schema, which is verification of Entities, Attributes, and Relationships.
6/24/2023 Database Design 8
Example of conceptual data model

6/24/2023 Database Design 9


Logical Database Design
• Logical design is the process of constructing a model of the information
used in an enterprise based on a specific data model (e.g. relational,
hierarchical or network or object), but independent of a particular DBMS
and other physical considerations.
Normalization process
• Collection of Rules to be maintained
• Discover new entities in the process
• Revise attributes based on the rules and the discovered Entities

6/24/2023 Database Design 10


Example

6/24/2023 Database Design 11


Cont. …

6/24/2023 Database Design 12


Physical Database Design
• Physical design is the process of producing a description of the
implementation of the database on secondary storage.
• Defines specific storage or access methods used by database
• Describes the storage structures and access methods used to achieve
efficient access to the data.
• Tailored to a specific DBMS system Characteristics are function of DBMS
and operating systems
• Includes estimate of storage space

6/24/2023 Database Design 13


Example of physical data model

6/24/2023 Database Design 14


Cont. …

6/24/2023 Database Design 15


Conceptual Database Design
• Conceptual design revolves around discovering and analyzing
organizational and user data requirements

• The important activities are to identify:


✓ Entities

✓ Attributes
✓ Relationships
✓ Constraints

• And based on these components develop the ER model using ER diagrams


6/24/2023 Database Design 16
Entity
➢An entity can be a real-world object, either animate or inanimate,
that can be easily identifiable.

• For example, in a school database, students, teachers, classes, and


courses offered can be considered as entities.

• All these entities have some attributes or properties that give them
their identity.

6/24/2023 Database Design 17


Cont. …

➢Entity set: is a collection of similar types of entities. An entity set


may contain entities with attribute sharing similar values.

• For example, a Students set may contain all the students of a school;
likewise a Teachers set may contain all the teachers of a school from
all faculties.

6/24/2023 Database Design 18


Attributes
• Entities are represented by means of their properties, called attributes. All
attributes have values.

• For example, a student entity may have name, class, and age as attributes.

• There exists a domain or range of values that can be assigned to attributes.

• For example, a student's name cannot be a numeric value.

✓It has to be alphabetic.

✓A student's age cannot be negative, etc.

6/24/2023 Database Design 19


Types of Attributes
➢Simple attribute: Simple attributes are atomic values, which cannot be
divided further.

• For example, a student's phone number is an atomic value of 10 digits.

➢Composite attribute: Composite attributes are made of more than one


simple attribute.

• For example, a student's complete name may have first_name and


last_name.

6/24/2023 Database Design 20


Cont. …

➢Derived attribute: Derived attributes are the attributes that do not


exist in the physical database, but their values are derived from other
attributes present in the database.

• For example, average_salary in a department should not be saved


directly in the database, instead it can be derived.

• For another example, age can be derived from data_of_birth.

6/24/2023 Database Design 21


Cont. …
➢Single-value attribute: Single-value attributes contain single value.

• For example Social_Security_Number.

➢Multi-value attribute: Multi-value attributes may contain more than


one values.

• For example, a person can have more than one phone number,
email_address, etc.

6/24/2023 Database Design 22


Cont. …
Keys
• Key is an attribute or collection of attributes that uniquely identifies an
entity among entity set.
• For example, the roll_number of a student makes him/her identifiable
among students.
➢Super Key: A set of attributes (one or more) that collectively identifies an
entity in an entity set.
• There is no any difference between supper key and key.

6/24/2023 Database Design 23


Cont. …
➢Candidate Key: A minimal super key is called a candidate key.

• A super key such that no proper subset is a super key within the
relation

• An entity set may have more than one candidate key.

➢Primary Key: A primary key is one of the candidate keys chosen by


the database designer to uniquely identify the entity set.

6/24/2023 Database Design 24


Cont. …

Relationship

• The association among entities is called a relationship.

• For example, an employee works_at a department, a


student enrolls in a course.

• Here, Works_at and Enrolls are called relationships.

6/24/2023 Database Design 25


The Entity Relationship (E-R) Model
• Entity-Relationship modeling is used to represent conceptual view of the database.

• The main components of ER Modeling are:

Entities

• Corresponds to entire table, not row

• Represented by Rectangle

Attributes

• Represents the property used to describe an entity or a relationship

• Represented by Oval

6/24/2023 Database Design 26


Cont. …

Relationships

• Represents the association that exist between entities

• Represented by Diamond

Constraints

• Represent the constraint in the data

• Cardinality and Participation Constraints

6/24/2023 Database Design 27


Cont. …

6/24/2023 Database Design 28


Developing an E-R Diagram
▪ Designing conceptual model for the database is not a one linear process
but an iterative activity where the design is refined again and again.
▪ To identify the entities, attributes, relationships, and constraints on the data,
there are different set of methods used during the analysis phase.
▪ These include information gathered by…
✓ Interviewing end users individually and in a group
✓ Questionnaire survey
✓ Direct observation
✓ Examining different documents

6/24/2023 Database Design 29


Cont. …
➢The basic E-R model is graphically depicted and presented for review.

➢ The process is repeated until the end users and designers agree that the E-R
diagram is a fair representation of the organization’s activities and functions.

➢Relationships between entities indicate access from one entity to another -it is
therefore possible to access one entity occurrence from another entity occurrence
even if there are other entities and relationships that separate them - this is often
referred to as Navigation' of the ER diagram

➢ The last phase in ER modeling is validating an ER Model against requirement


of the user.
6/24/2023 Database Design 30
Graphical Representations in ER Diagramming
• Entity is represented by a RECTANGLE containing the name of the
entity.

• Connected entities are called relationship participants Attributes are


represented by OVALS and are connected to the entity by a line.

6/24/2023 Database Design 31


Cont. …
• A derived attribute is indicated by a DOTTED LINE.(……..).

• PRIMARY KEYS are underlined.

• Relationships are represented by DIAMOND shaped symbols


• Weak Relationship is a relationship between Weak and Strong Entities
• Strong Relationship is a relationship between two strong Entities

6/24/2023 Database Design 32


Cont. …
• Example 1: Build an ER Diagram for the following information:

• A student record management system will have the following two


basic data object categories with their own features or properties:

• Students will have an Id, Name, Dept, Age, GPA, DOB, and Course
will have an Id, Name, Credit Hours Whenever a student enroll in a
course in a specific Academic Year and Semester, the Student will
have a grade for the course.

6/24/2023 Database Design 33


Cont. …

6/24/2023 Database Design 34


Cont. …
• Exercise: Build an ER Diagram for the following information:

• A Personnel record management system will have the following two


basic data object categories with their own features or properties:

• Employee will have an Id, Name, DoB, Age, Tel and Department will
have an Id, Name, Location Whenever an Employee is assigned in one
Department, the duration of his stay in the respective department
should be registered.

6/24/2023 Database Design 35


Types of relationship in ER model
➢One-to-one relationship: in a one-to-one relationship, one record in a table is
associated with one and only one record in another table.

• A customer is associated with at most one loan via the relationship borrower A
loan is associated with at most one customer via borrower.

6/24/2023 Database Design 36


Cont. …
• E.g.: Relationship Manages between STAFF and BRANCH

The multiplicity of the relationship is:

• One branch can only have one manager

• One employee could manage either one or no branches

6/24/2023 Database Design 37


Cont. …
➢One-To-Many Relationships: One-to-Many relationship in DBMS is
a relationship between instances of an entity with more than one
instance of another entity.

• In the one-to-many relationship a loan is associated with at most one


customer via borrower, a customer is associated with several
(including 0) loans via borrows.

6/24/2023 Database Design 38


Cont. …

6/24/2023 Database Design 39


Cont. …
• E.g.: Relationship Leads between STAFF and PROJECT

The multiplicity of the relationship

• One staff may Lead one or more project(s)

• One project is Lead by one staff

6/24/2023 Database Design 40


Cont. …
Many-To-Many Relationship

• A customer is associated with several (possibly 0) loans via borrower

• A loan is associated with several (possibly 0) customers via borrower

6/24/2023 Database Design 41


Cont. …
• E.g.: Relationship “Teaches” between INSTRUCTOR and COURSE

The multiplicity of the relationship

• One Instructor Teaches one or more Course(s)

• One Course Thought by Zero or more Instructor(s)

6/24/2023 Database Design 42


Participation of an Entity Set in a Relationship Set

• Participation constraint of a relationship is involved in identifying and


setting the mandatory or optional feature of an entity occurrence to
take a role in a relationship.

• There are two distinct participation constraints with this respect,


namely, Total Participation and Partial Participation

6/24/2023 Database Design 43


Cont. …

❖Total participation: every tuple in the entity or relation participates


in at least one relationship by taking a role.

• This means, every tuple in a relation will be attached with at least one
other tuple.

• The entity with total participation in a relationship will be connected


to the relationship using a double line.

6/24/2023 Database Design 44


Cont. …
➢ Partial participation: some tuple in the entity or relation may not
participate in the relationship.

• This means, there is at least one tuple from that Relation not taking
any role in that specific relationship.

• The entity with partial participation in a relationship will be connected


to the relationship using a single line.

6/24/2023 Database Design 45


Cont. …
• E.g. 1: Participation of EMPLOYEE in “belongs to” relationship with
DEPARTMENT is total since every employee should belong to a department.

• Participation of DEPARTMENT in “belongs to” relationship with

• EMPLOYEE is total since every department should have more than one
employee.

6/24/2023 Database Design 46


Cont. …
• E.g. 2: Participation of EMPLOYEE in “manages” relationship with
DEPARTMENT, is partial participation since not all employees are managers.

• Participation of DEPARTMENT in “Manages” relationship with EMPLOYEE is


total since every department should have a manager.

6/24/2023 Database Design 47


Converting ER Diagram to Relational Tables
• Three basic rules to convert ER into tables or relations:

➢Rule 1: Entity Names will automatically be table names

➢Rule 2: Mapping of attributes: attributes will be columns of the respective


tables.

✓ Atomic or single-valued or derived or stored attributes will be columns

✓ Composite attributes: the parent attribute will be ignored and the


decomposed attributes (child attributes) will be columns of the table.

6/24/2023 Database Design 48


Cont. …

• Multi-valued attributes: will be mapped to a new table where the


primary key of the main table will be posted for cross referencing.

➢Rule 3: Relationships: relationship will be mapped by using a foreign


key attribute.

✓Foreign key is a primary or candidate key of one relation used to


create association between tables.

6/24/2023 Database Design 49


Cont. …

✓For a relationship with One-to-One Cardinality: post the primary or


candidate key of one of the table into the other as a foreign key.

• In cases where one entity is having partial participation on the


relationship, it is recommended to post the candidate key of the
partial participants to the total participant so as to save some
memory location due to null values on the foreign key attribute.

6/24/2023 Database Design 50


Cont. …
• E.g.: for a relationship between Employee and Department where employee
manages a department, the cardinality is one-to-one as one employee will manage
only one department and one department will have one manager.

• Here the PK of the Employee can be posted to the Department or the PK of the
Department can be posted to the Employee.

• But the Employee is having partial participation on the relationship "Manages" as


not all employees are managers of departments. thus, even though both way is
possible, it is recommended to post the primary key of the employee to the
Department table as a foreign key.
6/24/2023 Database Design 51
Cont. …
✓For a relationship with One-to-Many Cardinality: Post the primary
key or candidate key from the “one” side as a foreign key attribute to
the “many” side.

• E.g.: For a relationship called “Belongs To” between Employee


(Many) and Department (One) the primary or candidate key of the one
side which is Department should be posted to the many side which is
Employee table.
6/24/2023 Database Design 52
Cont. …
✓ For a relationship with Many-to-Many Cardinality: for relationships having many to
many cardinality, one has to create a new table (which is the associative entity) and post
primary key or candidate key from the participant entities as foreign key attributes in the
new table along with some additional attributes (if applicable).

• The same approach should be used for relationships with degree greater than binary.

✓ For a relationship having Associative Entity property: in cases where the relationship
has its own attributes (associative entity), one has to create a new table for the
associative entity and post primary key or candidate key from the participating entities as
foreign key attributes in the new table.

6/24/2023 Database Design 53


Example in mapping ER to relational table
• The following ER has been designed to represent the requirement of an
organization to capture Employee Department and Project information.

• Employee works for department where an employee might be assigned to


manage a department. Employees might participate on different projects
within the organization. An employee might as well be assigned to lead a
project where the starting and ending date of his/her project leadership and
bonus will be registered.

6/24/2023 Database Design 54


Cont. …

6/24/2023 Database Design 55


Cont. …

• After we have drawn the ER diagram, the next thing is to map the ER
into relational schema so as the rules of the relational data model can
be tested for each relational schema.

• The mapping can be done for the entities followed by relationships


based on the rule of mapping.

• The mapping has been done as follows.

6/24/2023 Database Design 56


Cont. …
Mapping EMPLOYEE Entity:

• There will be Employee table with EID, Salary, FName and LName being the
columns.

• The composite attribute Name will be ignored as its decomposed attributes


(FName and LName) are columns in the Employee Table. The Tel attribute will be
a new table as it is multi-valued.

6/24/2023 Database Design 57


Cont. …
➢Mapping DEPARTMENT Entity:

• There will be Department table with DID, DName, and DLoc being the columns.

➢Mapping PROJECT Entity:

• There will be Project table with PID, PName, and PFund being the columns.

6/24/2023 Database Design 58


Cont. …
➢Mapping the MANAGES Relationship:

• As the relationship is having one-to-one cardinality, the PK or CK of


one of the table can be posted into the other. But based on the
recommendation, the Pk or CK of the partial participant (Employee)
should be posted to the total participants (Department).

• This will require adding the PK of Employee (EID) in the Department


Table as a foreign key.
6/24/2023 Database Design 59
Cont. …

• We can give the foreign key another name which is MEID to mean
"managers employee id". this will affect the degree of the Department
table.

6/24/2023 Database Design 60


Cont. …
➢Mapping the WORKSFOR Relationship:

• As the relationship is having one-to-many cardinality, the PK or CK of


the "One" side (PK or CK of Department table) should be posted to
the many side (Employee table).

• This will require adding the PK of Department (DID) in the Employee


Table as a foreign key.

6/24/2023 Database Design 61


Cont. …
• We can give the foreign key another name which is EDID to mean
"Employee's Department id". This will affect the degree of the
Employee table.

6/24/2023 Database Design 62


Cont. …
➢Mapping the PARTICIPATES Relationship:

• As the relationship is having many-to-many cardinality, we need to create a new


table and post the PK or CK of the Employee and Project table into the new table.

• We can give a descriptive new name for the new table like Emp_Partc_Project to
mean "Employee participate in a project".

6/24/2023 Database Design 63


Cont. …
➢Mapping the LEADS Relationship:

• As the relationship is associative entity, we are supposed to create a table for the
associative entity where the PK of Employee and Project tables will be posted in
the new table as a foreign key.

• The new table will have the attributes of the associative entity as columns.

• We can give a descriptive new name for the new table like Emp_Lead_Project to
mean "Employee leads a project".

6/24/2023 Database Design 64


Cont. …
• At the end of the mapping we will have the following relational
schema (tables) for the logical database design phase.
• After converting the ER diagram
in to table forms, the next phase
is implementing the process of
normalization, which is a
collection of rules each table
should satisfy.

6/24/2023 Database Design 65


Assignment
• Draw the relational schema for the following ER diagram:

6/24/2023 Database Design 66


6/24/2023 Database Design 67

You might also like