You are on page 1of 38

DATABASE DESIGN

AND MANAGEMENT
TS. NGUYỄN HOÀNG LONG
0916666384
nguyenhoanglong@humg.edu.vn
(HOMEWORK)
CHALLENGE 2-1

Create table(s) to manage the grades of


students in a module of a particular class.
GROUP DISCUSSION
Create table(s) to manage the grades of
students of a University.
SOLUTION
DATA REDUNDANCY
WHAT IS GOOD DATABASE DESIGN?

Provides Access with the


Divides your information
information it requires to
into subject-based tables
join the information in the
to reduce redundant data.
tables together as needed.

Helps support and ensure Accommodates your data


the accuracy and integrity processing and reporting
of your information. needs.
PHASES OF DATABASE
DESIGN
• Requirements: Requirements are normally come from
your clients/BA team
• Conceptual Design: the ER model is used for the
conceptual design of the database.
• Logical Design: Logical Design represents data in the
form of relational model. ER diagram produced in the
conceptual design phase is used to convert the data into
the Relational Model.
• Physical Design: In physical design, data in relational
model is implemented using a DBMS (mySQL,
PostGreSQL, Oracle, SQL Server, …)
CONCETPTUAL DESIGN
ER MODEL
ER Model is used to model the logical view of the system from data perspective which consists
of these components

Entity Entity
Entity
Type Set
ENTITY
• An Entity may be an object with a
physical existence – a particular
person, car, house, or employee – or
it may be an object with a
conceptual existence – a company,
a job, or a university course.
• An Entity is an object of Entity Type
and set of all entities is called as
entity set.
• E.g. student_1 and student_2 are
entities having Entity Type Student
and set of all students is called
Entity Set.
ATTRIBUTE(S)

Attributes are the properties which define the entity type.

Student_ID, Name, Age, Gender, Mobile_No are the attributes


which defines entity type Student.

In ER diagram, attribute is represented by an oval.


ATTRIBUTE(S) OF
STUDENT ENTITY TYPE

student_id …

student_name

student

major
An attribute composed of many other attribute is called
as composite attribute. For example, Address attribute of
student Entity type consists of Street, City, State, and
Country.
COMPOSITE In ER diagram, composite attribute is represented by an
ATTRIBUTE oval comprising of ovals.
MULTIVALUED ATTRIBUTE

An attribute consisting more than one


value for a given entity. For example,
Phone_No (can be more than one for
a given student). In ER diagram,
multivalued attribute is represented
by double oval.
DERIVED ATTRIBUTE

An attribute which can be derived


from other attributes of the entity type
is known as derived attribute. e.g.;
Age (can be derived from DOB). In
ER diagram, derived attribute is
represented by dashed oval.
ENTITY TYPE
The complete entity type Student with its attributes can be represented as
PRACTICE 3-1

Create a database to manage the grades of


students of a University.

How many entities?


GROUP DISCUSSION

Attributes of each entity?

Draw entity type of each entity


SOLUTION - 1
STUDENT ENTITY TYPE
student_id subject

student_name student grade

major class
DATA REDUNDANCY
SOLUTION - 2
STUDENT ENTITY TYPE
student_id Subject_id

student_name

student grade

major

class
SOLUTION - 2
SUBJECT ENTITY TYPE
subject _id …

subject _name

subject

number_of
_credits
SOLUTION - 3
… ENTITY TYPE

??? …

???

???

???
SOLUTION - 3
STUDENT ENTITY TYPE
student_id major

student

class
student_name
SOLUTION - 3
SUBJECT ENTITY TYPE
subject _id …

subject _name

subject

number_of
_credits
LOGICAL DESIGN
RELATIONAL MODEL
• Each entity types need to be converted to Relational models which can directly be
implemented by any RDBMS
• Relational Model was proposed by E.F. Codd to model data in the form of relations or tables.
• Relational Model represents how data is stored in Relational Databases.

student_id

Field name Data type Descriptions


student_id INT Student ID
student_name student
student_name VARCHAR(50) Name of the student
Major VARCHAR(20) Major of the student

major
PRACTICE 3-2

Converted your designed entities to


GROUP DISCUSSION
relational models
PHASES OF DATABASE
DESIGN
• Requirements: Requirements are normally come from
your clients/BA team
• Conceptual Design: the ER model is used for the
conceptual design of the database.
• Logical Design: Logical Design represents data in the
form of relational model. ER diagram produced in the
conceptual design phase is used to convert the data into
the Relational Model.
• Physical Design: In physical design, data in relational
model is implemented using a DBMS (mySQL,
PostGreSQL, Oracle, SQL Server, …)
PRACTICE 3-3

Create databases in a DBMS based on the


relational models from practice 3-3

Insert data into the created database

Discuss about the the data redundancy in


the created database
DATA REDUNDANCY
RELATIONSHIP TYPE

A relationship type represents the


association between entity types. For
example,‘Enrolled in’ is a relationship
type that exists between entity type
Student and Course.
In ER diagram, relationship type is
represented by a diamond and
connecting the entities with lines.
RELATIONSHIP SET

A set of relationships of same type is


known as relationship set. The
following relationship set depicts S1
is enrolled in C2, S2 is enrolled in C1
and S3 is enrolled in C3.
DEGREE OF A RELATIONSHIP SET

• The number of different entity sets participating in a


relationship set is called as degree of a relationship Unary Binary
set
• Based on the number of linked entity types, we have
4 types of degrees of relationships. Ternary N-ary
UNARY RELATIONSHIP

• When there is only ONE entity set


participating in a relation, the
relationship is called as unary
relationship.
• For example, one person is married
to only one person.
BINARY RELATIONSHIP

• When there are TWO entities set


participating in a relation, the
relationship is called as binary
relationship.
• For example, Student is enrolled in
Course.
TERNARY RELATIONSHIP

When there is a relationship between


three different entities, it is known as
a ternary relationship
PRACTICE 3-1
SOLUTION
subject subject
student_id major
_id _id

Enroll subject
student subject
in _name

student_na class number_of


student_id
me _credits
PRACTICE 3-4

Converted the designed entities and


relationships to relational models

Create databases in a DBMS based on the


relational models
GROUP DISCUSSION

Insert data into the created database

Discuss about the the data redundancy in


the created database
PRACTICE 3-5

Create a database to manage the order for


a restaurant

How many entities?


GROUP DISCUSSION

Attributes of each entity?

Define the relationships between entities


HOMEWORK

Draw the relationships between them

Converted your designed entities and


GROUP DISCUSSION relationships to relational models

Create databases in a DBMS based on the


relational models

Insert data into the created database

Discuss about the the data redundancy in


the created database

You might also like