chapter two Data Model
chapter two Data Model
===============================================================
CHAPTER TWO
Database System Architecture A Classification
of DBMS
The actual data in a database may change quite frequently. For example, the database shown in
changes every time we add a new student or enter a new grade. The data in the database at a
particular moment in time is called a database state or snapshot. It is also called the current set
of occurrences or instances in the database.
A specific DBMS has its own specific Data Definition Language, but this type of
language is too low level to describe the data requirements of an organization in a way
that is readily understandable by a variety of users. We need a higher-level language.
Such a higher-level is called data-model.
Data Model: a set of concepts to describe the structure of a database, and certain
constraints that the database should obey.
A data model is a description of the way that data is stored in a database. Data
model helps to understand the relationship between entities and to create the most
effective structure to hold data.
Data Model is a collection of tools or concepts for describing
Data
Data relationships
Data semantics
Data constraints
The main purpose of Data Model is to represent the data in an understandable way.
Categories of data models include:
Record-based
Physical
Object-based
Record-based Data Models
Consist of a number of fixed format records. Each record type defines a fixed number of
fields, Each field is typically of a fixed length.
Hierarchical Data Model
Network Data Model
Relational Data Model
1. Hierarchical Model
The simplest data model
Department
Employee Job
Department Job
Employe
e Activity
Time card
All values in a column represent the same attribute and have the same data format
Weak entity: an entity that can not exist without the entity with which it has a
relationship – it is indicated by a double rectangle
2. The ATTRIBUTES - the items of information which characterize and describe
these entities.
Attributes are pieces of information ABOUT entities. The analysis must of course
identify those which are actually relevant to the proposed application. Attributes will give
rise to recorded items of data in the database
At this level we need to know such things as:
• Attribute name (be explanatory words or phrases)
• The domain from which attribute values are taken (A DOMAIN is a set
of values from which attribute values may be taken.) Each attribute has
values taken from a domain. For example, the domain of Name is
string and that for salary is real
• Whether the attribute is part of the entity identifier (attributes which just
describe an entity and those which help to identify it uniquely)
• Whether it is permanent or time-varying (which attributes may change their
values over time)
• Whether it is required or optional for the entity (whose values will
sometimes be unknown or irrelevant)
Types of Attributes
(1) Simple (atomic) Vs Composite attributes
• Simple: contains a single value (not divided into sub parts) E.g. Age,
gender
• Composite: Divided into sub parts (composed of other attributes)
E.g. Name, address
(2) Single-valued Vs multi-valued attributes
• Single-valued: an attribute that holds a single value for a single entity.
Cardinality of a Relationship
• Another important concept about relationship is the number of instances/tuples that can
be associated with a single instance from one entity in a single relationship. The number
of instances participating or associated with a single instance from an entity in a
relationship is called the CARDINALITY of the relationship. The major cardinalities of a
relationship are:
ONE-TO-ONE: one tuple is associated with only one other tuple.
A B
a b
a b
a b
a
b
E.g. Building – Location - as a single building will be located in a single location and as
a single location will only accommodate a single Building.
ONE-TO-MANY, one tuple can be associated with many other tuples, but not the
reverse.
A B
a b
a b
a b
b
E.g. Department-Student -as one department can have multiple students.
MANY-TO-ONE, many tuples are associated with one tuple but not the reverse.
E.g. Employee – Department: as many employees belong to a single department.
MANY-TO-MANY: one tuple is associated with many other tuples and from the other
side, with a different role name one tuple will be associated with many tuples
A B
a
b
a
b
a
b
a b
8 Compiled by Seada A. 2010
Database Management System Lecture Notes
===============================================================
E.g. Student – Course-as a student can take many courses and a single course can be
attended by many students.
Instances
Instance: is the collection of data in the database at a particular point of time (snap-shot).
Also called State or Snap Shot or Extension of the database
Refers to the actual data in the database at a specific point in time
State of database is changed any time we add, delete or update an item.
Valid state: the state that satisfies the structure and constraints
specified in the schema and is enforced by DBMS
Since Instance is actual data of database at some point in time, changes rapidly
To define a new database, we specify its database schema to the DBMS (database is
empty) .
Database is initialized when we first load it with data .
Some of the more common types of object based data model are:
• Entity-Relationship
• Object Oriented
• Semantic
• Functional
The Entity-Relationship model has emerged as one of the main techniques for modeling
database design and forms the basis for the database design methodology. The object
oriented data model extends the definition of an entity to include, not only the attributes
that describe the state of the object but also the actions that are associated with the object,
that is, its behavior. The object is said to encapsulate both state and behavior. Entities in
semantic systems represent the equivalent of a record in a relational system or an object
in an OO system but they do not include behavior (methods). They are abstractions ‘used
to represent real world (e.g. customer) or conceptual (e.g. bank account) objects. The
functional data model is now almost twenty years old. The original idea was to’ view the
database as a collection of extensionally defined functions and to use a functional
language for querying the database.