4 CC104 DataMOdel-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 49

CC104

DATA
MODEL
Objectives
In this chapter, you will:
o Explain data modeling
o Recognize the importance of data models
o Define the business rules and explain the
influence in designing a database
o Explain the evolution of data models
o Design data models and identify basic
cardinalities based on given business rules.
Data Modeling and Data
Models
Database design primarily focuses on
the processing and handling of end-
user data using the database structure.
In developing a database, the first phase
is data modeling, which refers to
creating a data model for a given
problem domain.
Data Model
A data model is a visual
representation of a real-world data
structure. It displays data
representation and how the data can
be accessed.
The various features, changes,
and constructs on a particular
database based on a domain and
collection of business rules or
specifications are illustrated using a
data model.
Problem Domain
It is a defined collection of scope and
boundaries based on a real-world
area or situation projected to be
solved.
The Importance of Data
Models
1. It facilitates interaction between
the designer, the application
programmer, and the end-user.
2. It allows a better understanding
of a particular organization for which
the database is intended to be built.
3. It serves as the database’s
blueprint.
A database blueprint is a special
file that contains a complete
specification for the structure of a
database, including all fields, forms,
and procedures.
Types of Database Models
1. Flat File Model
2. Hierarchical Model
3. Network Model
4. Object-Oriented Model
5. Relational Model
Flat File Model
It is a database model that utilizes a
single table design. It may have many
fields that are prone to data
inconsistency, redundancy, and
corruption. You can use the copy and
paste method to copy data from different
flat files, and automation is not allowed.
Delimiters like tabs and commas are used
to separate files in the record.
Flat File Model

Source: https://www.researchgate.net/figure/Example-of-a-Flat
File_fig1_291448084
Hierarchical Model
The data is stored organized in a
tree-like structure, and records are
interconnected through links. The
data can be retrieved by traversing
the whole tree starting from the root.
Hierarchical Model

Source:Carlos Coronel, Steve Morris, Peter Rob, Database Systems: Design,


Implementation, and Management, Ninth Edition 2015
Network Model
The network model is known for its
flexible way of representing data. The
structure follows a graph format
where objects are nodes and
relationships are arcs.
Object-Oriented Model
The object-oriented
model envisions
entities as objects.
Each object has
attributes (state) and
methods (behavior).
An object belongs to
a single class only
and as its instance.
Relational Model
The relational model views a
database as a set of tables with
columns and rows. Each table
represents an entity or a data source.
Each row is an instance of that entity.
Keys uniquely identify such rows. And
each column is the attribute or
property of the entity.
Relational Model
Features of a Relational
Database Model
• Rows and columns can be in any order.
• Every row is unique so that there is a
specific value in each row that is
different from the value in the other
row.
• A field can only contain one value.
• Values under a column of fields are from
a similar domain.
• Table names and so as its column names
must be unique.
Entity Relationship
Diagram (ERD)
Entity Relationship Diagram is a
modeling technique to represent the
database components and the
relationships between entities.
ERD Components
1. Entity
2. Relationship
3. Attribute
4. Cardinalities
Entity
• person, place, thing, or event that we
want to store information about
• denoted by a NOUN
• represented by a rectangle shape in the
ERD
Question:
What entity is relevant to each of these areas:
- school
- real estate agency
- library
Examples of entity
• School
- students, faculty and classes
• Real estate agency
- clients, houses and agents
• Library
- books, borrowers
Relationship
• Association between entities
• describes the relationship between two entities
• denoted by a VERB (passive or active)
• represented by a diamond shape In the ERD

Example
- relationship between customer and sales rep
- relationship between teacher and class
Attribute
• Property of an entity
• data collected about the entities
• represented by an oval shape in the ERD

Example:
What attributes can you identify for the ff:
- person
- customer
- faculty
Cardinalities
• the number of times an instance of an
entity can relate to instances of other
entities
• often symbolized by the crow's foot
notation
Basic Cardinalities
One-to-one

One employee belongs in one office


One-to-many

may be connected to a
One sales rep number of customers.
Many-to-many

Students library
borrowers books
Other Symbols/Notations:

Zero or one (optional)

Zero or many (optional)


Examples:
Three ways to do ERD
Three ways to do ERD
Three ways to do ERD
Three ways to do ERD
Degree of Relationships

The degree of a relationship is


based on the entities that are related
to each other. There are three types
of degree and these are as follow:
Unary Relationship
when the relationship that exists is within the
same entity.
Binary Relationship
when a relationship exists between
two different entities.
Ternary Relationship
• when three entities share a
relationship.
Business Rules
A business rule is a specific
description of a company's policy or
procedure. It states how an
organization does things in terms of
its transactions and operations.
These rules are used in the
identification of the entities,
attributes, relationships, and
constraints.
Examples:
Each student can register for one or
more classes.

Each class can have many students.

Each teacher can only handle a


maximum of 30 students.
Bi-directional:
Each employee works in one store.
Each store has many employees.

Each engineer borrows one or more


gadgets. Each gadget is borrowed by
one engineer.
Business Rules Translation
Translating business rules into
database components requires
analysis and understanding. Here are
some tips to spot the significant
components easily.
Business Rules Translation
A noun in a business rule is a possible
entity.
Example:
Business rule: Each student can
register for one or more classes.
Entities: Student and Class
Business Rules Translation
A verb that associates the nouns is a
possible relationship.
Example:
Business rule: Each student can
register for one or more classes.
Entities: Student and Class
Relationship: registers
To determine the relationship type by
asking"how many" questions. In the
example above, you can ask:

1. How many classes can a student


register for? Many

2. How many students can a class


have? Many
Additional information about an entity is
the attributes.
Examples:
• Student attributes: student_name, student_id,
student_course
• Class attributes: class_code, class_name,
class_adviser
End. ☺

You might also like