Chapter 2 Data Models
Chapter 2 Data Models
Data Models
DATA MODELLING OVERVIEW
▪ In the previous Chapter, we described that Database Design focuses on how the
database structure will be used to store and manage end-user data.
What is Data Modelling?
▪ On the other hand, Data Modelling is the first step in designing a database and
refers to the process of creating a specific data model for a determined
problem domain.
What is a Data Model?
▪ A data model is a conceptual representation of the data structures that are
required by a database. The data structures include:
▪ data objects
▪ the associations between data objects
▪ the rules which govern operations on the objects.
DATA MODELLING OVERVIEW
▪ A data model is a relatively simple representation, usually graphical, of
more complex real-world data structures.
▪ The data model focuses on:
▪ what data is required
▪ how it should be organized
▪ The data model is an abstraction; you cannot draw the required data out of the
data model.
▪ For example, think of a house plan or blueprint, you cannot live in a blueprint and
architects consider blueprints before constructing a building.
THE IMPORTANCE OF DATA MODELS
▪ A data model’s main function is to help you understand the complexities of the real-world environment.
▪ The goal of the data model is to make sure that the all data objects required by the database are
completely and accurately represented. Because the data model uses easily understood notations and
natural language, it can be reviewed and verified as correct by the end-users.
▪ The data model is also detailed enough to be used by the database developers as a “blueprint” for
building the physical database.
▪ The information contained in the data model will be used to define the relational tables, primary and
foreign keys, stored procedures, and triggers.
▪ The data model also acts as a communication tool to facilitate interaction among the designer, the
applications programmer, and the end user. End-users have different views and needs for data from the
designers and programmers. A well-developed data model can even foster improved understanding of
the organization.
COMPONENTS OF DATA MODELS
There are four (4) component of a database model:
▪ Entity: an entity is anything (a person, a place, a thing, or an event) about which data are to
be collected and stored. An entity represents a particular type of object in the real world.
▪ Attribute: an attribute is a characteristic of an entity.
▪ Relationship: a relationship describes an association among entities. Relationships can be
thought of as verbs, linking two or more nouns.
▪ Constraint: a constraint is a restriction placed on the data.
Example: department and a course are some of the important components of any academic
institution. In that case:
▪ the department and course are entities,
▪ the department name, course name, course code, etc. are attributes of these entities,
▪ a department has multiple courses and a course has a department is the relationship between these
entities
RELATIONSHIPS: THE BASIC CHEN ERD
▪ There are several protocols to the way business rules are written. Not every protocol has to be
followed.
CHARACTERISTICS OF BUSINESS RULES
▪ Business rules are brief, precise, and unambiguous descriptions of a policies,
procedures, or principles within a specific organization
▪ They apply to any organization that stores and uses data to generate information
▪ They are description of operations that help to create and enforce actions within that
organization’s environment
▪ They must be rendered in writing
▪ They must be kept up to date
▪ Sometimes they are external to the organization
▪ They must be easy to understand and widely disseminated
▪ They describe characteristics of the data as viewed by the company
IMPORTANCE OF BUSINESS RULES
▪ Business rules promote the creation of an accurate data model.
▪ They help standardize the company’s view of data.
▪ They can be a communication tool between users and designers.
▪ They allow the designer to:
▪ understand the nature, role, and scope of the data
▪ understand business processes
▪ develop appropriate relationship participation rules
▪ identify all constraints
▪ create an accurate data model.
EXAMPLES OF BUSINESS RULES
▪ Suppose there was a single company responsible for handling student
applications to different universities and it had the following business
rules:
▪ Each student can submit one application per university.
▪ Each application is submitted by only one student.
▪ Each university can be associated with one or more applications and each
application is associated with only one university
▪ Each application must include two or more recommendations and each
recommendation is included with only one application.
▪ From the above business rules identify all the entities and relationships
among the entities and draw a relational data model that include:
▪ All the entities
▪ At least three (3) attributes for each entity
▪ All the relationships among the entities
EVOLUTION OF DATA MODELS
▪ Hierarchical
▪ Network
▪ Relational
▪ Entity relationship
▪ Object oriented
EVOLUTION OF DATA MODELS
EVOLUTION OF DATA MODELS
HIERARCHICAL MODEL
▪ Developed in the 1960s to manage large amounts of data for complex
manufacturing projects
▪ Its basic logical structure is represented by an upside-down “tree”
▪ The hierarchical structure contains levels, or segments. A segment is
the equivalent of a file system’s record type.
▪ The hierarchical model employs two main data structuring concepts:
records and parent-child relationships (PCR).
▪ A record is a collection of field values that provide information on an
entity or a relationship instance.
HIERARCHICAL MODEL
▪ Records of the same type are grouped into record types. A record type
is given a name, and its structure is defined by a collection of named
fields or data items. Each field has a certain data type, such as integer,
real, or string.
▪ A parent-child relationship type (PCR type) is a 1:N relationship
between two record types. The record type on the 1-side is called the
parent record type, and the one on the N-side is called the child record
type of the PCR type.
▪ An occurrence (or instance) of the PCR type consists of one record of
the parent record type and a number of records (zero or more) of the
child record type as shown in the diagram below.
HIERARCHICAL MODEL
HIERARCHICAL MODEL
HIERARCHICAL MODEL
HIERARCHICAL MODEL
▪ The hierarchical model depicts a set of one-to-many (1:M) relationships
between a parent and its children segments:
▪ Each child has only one parent except root node.
▪ Each parent can have many children ordered from left to right.
4
2.1.2 SOME POPULAR RDBMS PACKAGES
1. Oracle RDBMS
2. IBM DB2
3. Microsoft SQL Server
4. SAP Sybase ASE
5. Teradata
6. ADABAS
7. MySQL
8. FileMaker
9. Microsoft Access 5
2.1.13 COMPONENTS OF RELATIONAL
DATABASE STRUCTURAL TERMINOLOGY
Relation
•a table with columns and rows
7
2.1.13 COMPONENTS OF RELATIONAL
DATABASE STRUCTURAL TERMINOLOGY
Exercise:
Identify:
a. Name of the relation.
b. Cardinality of the relation.
c. Degree of the relation.
d. Suitable domain for column Type.
e. Suitable domain for column Date of Birth.
8
2.1.4 APPLICATION AREA OF RDBMS
Airlines : reservations, schedules
Banking : all transactions
supply chain
Human resources: employee records, salaries, tax
deductions
9
2.1.5 PROPERTIES OF TABLES IN A
RELATIONAL DATABASE
Each Each
column
row is must have
a unique
unique name 10
2.1.6 CHARACTERISTICS OF RELATION
SCHEME
Relation scheme
Named relation defined by a set of attribute and
domain name pairs.
Characteristics:
a. Relation name
b. Attribute name
c. Domains
Syntax:
RelationName (attribute-1, attribute-2…attribute-n) 11
2.1.6 CHARACTERISTICS OF RELATION
SCHEME
Example:
Table name: Animal_Vaccination
12
2.1.7 RELATION INSTANCE
A tuple at a specifc moment of time
Eg: Student (StudentId, firstName, lastName, courseId)
The relation instance for Student:
(L0002345, Jim, Black, C002)
(L0001254, James, Harradine, A004)
The relation instance changed when the tuple is updated,
deleted or inserted
13
2.1.8 RELATION KEYS
1) Candidate key
- Any set of one or more columns whose combined values are
unique among all occurrences (i.e., tuples or rows).
- No component of a candidate key is allowed to be null.
- There can be any number of candidate keys in a table.
14
2.1.8 RELATION KEYS
2) Primary key (identifier)
- Any candidate key of that table which the database
designer arbitrarily designates as "primary".
- The primary key may be selected for convenience,
comprehension, performance, or any other reasons.
15
2.1.8 RELATION KEYS
16
2.1.8 RELATION KEYS
17
2.1.8 RELATION KEYS
Exercise:
Identify:
i. candidate key
ii. primary key
18
2.1.9 INTEGRITY RULES
Data integrity means that the data values in the
database are correct and consistent.
Integrity constraints provide a way of ensuring that changes
made to the database by authorized users do not result in a
loss of data consistency
19
2.1.9 INTEGRITY RULES
1) Entity Integrity
- states that “for every instance of an entity, the value of the
primary key must exist, be unique, and cannot be null”
- Without entity integrity, the primary key could not fulfill its
role of uniquely identifying each instance of an entity
2) Referential Integrity
- states that “every foreign key value must match a primary
key value in an associated table”
- ensures that we can correctly navigate between related
entities
20
2.1.9 INTEGRITY RULES
Exercise:
Identify:
a. Suggest suitable name for the relation. Senior_Citizen, Member, Neighbour
b. Cardinality of the relation.
c. Degree of the relation.
d. Suitable domain for column Last Name.
e. Suitable domain for column City.
22
f. Suitable domain for column Age.
EXERCISE
Identify:
a. Suggest suitable name for the relation.
b. Cardinality of the relation.
c. Degree of the relation.
d. Suitable domain for column ID.
e. Suitable domain for column Class.
23
f. Suitable domain for column Mark.