Unit I Data Models
Unit I Data Models
of DBMS
By
Dr. Rifaqat Ali
Department of Mathematics and Scientific Computing
National Institute of Technology Hamirpur
Email id : [email protected]
Schema:
A schema is plan of the database that give the names of the entities
and attributes and the relationship among them.
A schema includes the definition of the database name, the record
type and the components that make up the records.
Alternatively, it is defined as a frame-work into which the values of
the data items are fitted.
The values fitted into the frame-work changes regularly but the
format of schema remains the same.
For Example: Consider the database consisting of three files ITEM,
CUSTOMER and SALES.
There are two types of Schema:
The logical schema: provides the conceptual view that defines the
relationship between the data entities.
Any changes made in logical schema have minimal effect in the physical
schema.
Logical schema includes attributes.
Examples: Entity Relationship diagram, Unified Modeling Language, class
diagram.
The physical schema: describes the way of storage of data in the disk.
Changes in Physical schema effects the logical schema.
Physical schema does not include attributes.
Examples: Data definition language(DDL), storage structures, indexes.
Subschema: is a subset of the schema having the same properties
that a schema has.
Each user is able to access the same data but have a different
customized view of the data as per the requirement.
The changes to physical storage organization does not affect the
internal structure of the database.
e.g., moving the database to a new storage device
To use the database, the user is no need to concern about the physical
data storage details.
The conceptual structure of the database can be changed by the DBA
without affecting any user.
The database storage structure can be changed by the DBA without
affecting the user’s view.
Data Independence:
It is defined as the characteristics of a database system to
change the schema at one level without having to change the
schema at the next higher level.
It can also be defined as the immunity of the application
programs to change in the physical representation and access
techniques of the database.
The above definition says that the application programs do not
depend on any particular physical representation or access
technique of the database.
The data independence is of Two types: Physical and Logical
Physical Data Independence:
The physical storage structures used for storing the data could
be changed without changing the conceptual view or any of the
external views.
Only the mapping between the conceptual and internal level is
changed.
Logical Data Independence:
The conceptual schema can be changed without changing the
existing external schemas.
Only the mapping between the external and conceptual level is
changed and absorbed all the changes of the conceptual
schema.
Data Models
• A data model is used to describe the structure of the database
including data types, relationships and the constraints that apply
on the data.
• A data model helps in understanding the meaning of the data
and ensures in the following way:
The data requirements of each user.
The use of data across various applications.
The nature of data independent of its physical representations.
• A data model supports communication between the users and
database designers.
Characteristics of Data Models:
• In this model, the data is represented in the form of tables which is used
interchangeably with the word Relation.
• Each table consists of rows also knowns as tuples (A tuple represents a
collection of information about an item, e.g., student record) and column
also known as attributes. (An attribute represents the characteristics of an
item, e.g., Student’s Name and Phone No.).
Advantages: it is structurally independent, improved conceptual simplicity
adhoc query capability and powerful DBMS.
Disadvantages: are substantial hardware and software overhead and
facilitates poor design and implementation.
(ii) Object Based Data Models: These models are used in
describing the data at the logical and user view levels.
These models allow the users to implicity specify the constraints
in the data.
Further categorised into four types:
a) Entity Relationship Model (ER-Model)
b) Object Oriented Model
c) Semantic Data Model
d) Functional Data Model
a) Entity Relationship Model (ER-
Model)
• The E-R model is a high level conceptual data model developed by Chen in
1976 to facilitate database design.
• The E-R model is the generalization of earlier available commercial model
like the hierarchical and network model.
• It also allows the representation of the various constraints as well as their
relationships.
• Advantages: it is conceptually simple, an effective communication tool and
can be integrated with the relational data model.
• Disadvantages: there are limited constraint representation, limited
relationship representation, no data manipulation language and loss of
information content.
b) Object Oriented Model
• It is a logical data model that captures the semantics of objects supported in
an object-oriented programming.
• It is based on collection of objects, attributes and relationships which together
form the static properties.
• An object is a collection of data and methods. When different objects of same
type are grouped together they form a class. This model is used basically for
multimedia applications as well as data with complex relationships.
Advantages: Capability to handle various data types, improved data access,
and improved productivity.
Disadvantages: Not suitable for all applications, No precise definition, and
Difficult to maintain.
c) Semantic Data Model
• These models are used to express greater interdependencies among
entities of interest.
• These interdependencies enable the models to represent the semantic of
the data in the database.
• The functional data model describes those aspects of a system concerned with
transformation of values-functions, mappings, constraints and functional
dependencies.
Comparison of Various Data Models
(iii) Physical Data Models: These models provide the concepts that
describes the details of how the data is stored in the computer along
with their record structures, access paths and ordering.
Further divided into two types:
a) Unifying Model: is expressed as Unified Modeling Language (UML).
Class diagrams to capture the logical structure of a domain as a set
of classes, their features (attributes), and the relationships
(associations) between them.
b) Frame Memory Model: is a virtual view of secondary storage that
can be implemented with reasonable overhead to support database
record storage and accessing requirements.
Note that: Only specialized or professional users can use these models.
Database Languages:
The generalized database language, which is common in all databases, is
Structured Query Language (SQL).
It is divided into the following four parts: DDL, DML, DCL, and TCL
1. Data Definition Language (DDL): The database language which is used to
define database objects; to drop database objects; to alter (change) database
objects, such as tables, views, users, is known as Data Definition Language
(DDL).
For example:
DDL to create a ZONE table.
Create table zone (zoneid integer, zonename char(20));
DDL to alter a ZONE table which changes the data type of a zoneid from
integer to char(1).
Alter table zone modify column zoneid char(1);
DDL to drop (delete) a ZONE table.
Drop table zone;
Continued….
2. Data Manipulation Language (DML): The database language, which is
used to insert data, manipulate data; delete data or retrieve data in tables or
views, is known as Data Manipulation Language (DML).
For example:
DML to insert data in a ZONE table.
Insert into zone values(1, ‘North’);
DML to change the value of zonename from ‘North’ to ‘East’ for
zoneid = 1.
Update zone set zonename = ‘East’ where zoneid = 1;
DML to delete a record of zoneid 1 from ZONE table.
Delete from zone where zoneid = 1;
DML to retrieve a record of zoneid 1 from ZONE table.
Select * from zone where zoneid = 1;
Continued….
Note that: Data Sub Language (DSL): The combination of Data Definition
Language and Data Manipulation Language is known as Data Sub Language
(DSL).
Difference between Data Independence and Structural Independence: