A
data model is a collection of conceptual for describing –
Data
Data relationships,
Data semantics, and
Consistency constraints.
In other words, a data model
describes the structure of a database.
Data models are either logical data
model or physical data model. Logical data models can further be divided into
two categories as given below.
1. Object-based logical
data models (logical data models).
2. Record-based
logical data models (logical data models).
All
of these data models are described in following sub-sections.
1. Object-based
logical data models
Object-based logical data models are used in
describing data at the logical and view
levels. Some of
the well-known object-based logical data models are-
The entity-relationship
model
The object-oriented
model
The binary model
The semantic data model
The functional data
model
Among all these models, entity-relationship
model and object-oriented model are described in brief here.
1.
Entity-relationship
model
The
entity-relationship model is based on a perception of a real world. a real
world
consists of a
collection of basic objects and relationship among these objects. This model is
also referred as the E-R model.
These basic objects are called
entities. They are distinguishable from other entities. For example, each
customer is an entity. Also, each account is an entity.
A set of attributes or properties is
associated with each entity to describe it. For example, account number and
balance describe one particular account in a bank. The set of all entities of
the same type is called the entity set. So, customer can be considered as an
entity-set and all individual customers are entities.
An association among several
entities is known as relationship. For example, an Account_Holder relationship
associates a customer with each account he/she has. A set of all relationships
of the same type is called relationship set.
Along with entities and
relationships, the E-R model represents certain constraints. The contents of a
database must conform to these constraints. On important constraint is mapping
cardinalities. Mapping cardinalities express the number of entities to which
another entity can be associated via a relationship set.
The overall logical structure of a
database is represented graphically by E-R diagram.
The entity-relationship model is widely
used in database design. Chapter 8 and 9 explores this model in detail.
2.
Object-oriented
model
The object-oriented model is also
based on a collection of objects, like as the E-R
model.
An object:
An object contains values stored in
instance variables within the object. An object also contains bodies of code
that operate on these values. These bodies of code are called methods. In other
words, object can be considered as-
Object = values in instance variables +
methods
A class:
Objects that contain the same types
of values and the same methods are grouped together into classed. A class may
be viewed as a type-definition for objects.
relational algebra in dbms
Sending a message:
The only way in which one object can
access data of another object is by invoking (calling) a method of that other
object. This is called sending a message to the object.
Two levels of data abstraction:
The call interface of the methods,
i.e. method names, of an object defines that object’s externally visible part.
The internal parts of the object - the
instance variables and method code – are not visible externally. The result is
two levels of data abstraction.
Consider an object account having
instance variable acc_no and balance, and
method pay_interest to add interest to balance. Assume that the bank
changes its policy to pay interests. It decides to pay 8% interest instead of
5%. This requires to change the code of pay_interest method only, rather than
changing the entire application program. The external interface, i.e. method
name, to the objects remains unchanged.
Distinction among objects:
Each object has its own unique
identity in this model. This identity is independent of th values that it
contains. Two objects containing the same values are distinct. This distinction
is create and maintained in physical level by assigning distinct object
identifiers.
2. Record-based
logical data models
Record-based
logical data models are also used in describing data at the logical and view
levels. They are used
to specify overall logical structure of the database, and to provide a higher
level description of the implementation.
In
this model, database is structured in fixed-format records of several types.
Each
record
type defines a fixed number of fields, or attributes. Each field is usually of
a fixed length. This simplifies the physical level implementation of the
database.
Some of the well-known record-based logical
data models are –
The
relational model
The
network model
The
hierarchical model
1. Relational
database model:
The relational
model uses a collection of tables to represent both data
and the relationships
among those data. Each table contains multiple columns. Each column has a
unique name and a fixed width.
A banking enterprise can have
several tables such as customer, account, loan, branch, employee, transaction,
account_holder, borrower, etc. The following figure depicts a sample relational
database having three tables – Customer, Account and Account_Holder.
Customer:
CID
|
NAME
|
SOCIETY
|
CITY
|
|||
C01
|
RIYA
|
AMUL AAVAL
|
ANAND
|
|||
C02
|
JIYA
|
SARDAR COLONY
|
KARAMSAD
|
|||
C03
|
PIYA
|
MARUTISADAN
|
VVNAGAR
|
|||
C04
|
DIYA
|
SARAL SOCIETY
|
ANAND
|
|||
C05
|
TIYA
|
BIRLA GRUH
|
VVNAGAR
|
|||
ANO
|
BALANCE
|
|||||
A01
|
5000
|
|||||
A02
|
6000
|
|||||
A03
|
7000
|
|||||
A04
|
8000
|
|||||
A05
|
6000
|
|||||
Account:
|
CID
|
ANO
|
C01
|
A01
|
C02
|
A02
|
C03
|
A03
|
C04
|
A04
|
C05
|
A05
|
Account_Holder:
Here,
Customer and Account table represents data about Customer and Accounts. Account_Holder
table represents relationships among Customers and Accounts. According to these
tables, a customer ‘RIYA’ from city ‘ANAND’ has customerID ‘C01’ and she has
Account having account numbers ‘A01’. An Account ‘A01’ has BALANCE Rs. 5000.
These tables also describe that
‘JIYA’ owns two Accounts-‘A02’ and ‘A04’. Also, an account ‘A04’ is jointly
acquired by Customer ‘C02’ and ‘C04’, means, ‘JIYA’ and ‘DIYA’.
Date Conversion in SQL
2. Network model
Data in network model are represented
by collections of records. A record is defined as a collection of
logically related data items. Relationships among data are represented by
links. Links can also be considered as pointers. The records in a database are
organized as collections of arbitrary graphs.
C01
|
RIYA
|
AMUL ALVAS
|
ANAND
|
A01 5000
C02
|
JIYA
|
SARDAR COLONY
|
KARAMSAD
|
A02 6000
C03
|
PIYA
|
MARUTISADAN
|
VVNAGAR
|
A03 7000
C04
|
DIYA
|
SARAL SOCIETY
|
ANAND
|
A04 8000
C05
|
TIYA
|
BIRLA GRUH
|
VVNAGAR
|
A05 6000
3. Hierarchical
model
The hierarchical
model is simply a special case of the network data model. Data are
represented by
collections of records as similar to network model. Relationships among data
are represented by links or pointers. The records in a database are organized
as collections of trees rather than arbitrary graphs.
Represents a sample hierarchical
database using the same information as in figure. Limited records have been
considered here.
BANK
|
C01
|
RIYA
|
AMUL AAVAS
|
ANAND
|
C02
|
JIYA
|
SARDAR COLONY
|
KARAMSAD
|
C05
|
TIYA
|
BIRLA GRUH
|
VVNAGAR
|
A01
|
5000
|
A02
|
6000
|
A05
|
6000
|
1. Physical data
models
Physical
data models are used for higher level description of storage structure and
access mechanism.
They
describe how data is stored in database. They represent information such as
record
structures, record orderings and access paths.
Some
of the well-known physical data models are –
The
unifying model
The
frame memory model
4. Comparison
between data models
DATA MODEL
|
DATA
ORGANIZATION
|
RELATIONSHIPS
|
IDENTITY
|
DATA
INDEPENDENCE
|
E-R
|
Entities
|
Relationships
|
Value-based
|
yes
|
Object-oriented
|
Objects
|
Recursive
object
|
Record-based
|
Yes
|
Relational
|
Tables
|
Tables
|
Value-based
|
Yes
|
Hierarchical
|
Files, Records
|
Pointers of
links
|
Record-based
|
Yes
|
Network
|
Files, Records
|
Pointers of
links
|
Record-based
|
yes
|
Post a Comment
Please do not enter any spam link in the comment box.