LM 2 - Views of Data Data Models
LM 2 - Views of Data Data Models
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Course Outcome
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Syllabus
UNIT I - RELATIONAL DATABASES
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
TOPIC
Views of Data
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Views of Data
• A database system is a collection of interrelated data and a set of programs
that allow users to access and modify these data.
• A major purpose of a database system is to provide users with an abstract view
of the data.
• Data models
• A collection of conceptual tools for describing data, data relationships,
data semantics, and consistency constraints.
• Data abstraction
• Hide the complexity of data structures to represent data in the database
from users through several levels of data abstraction.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction
• Abstraction is one of the main features of database systems.
• Hiding irrelevant details from user and providing abstract view of data
to users, helps in easy and efficient user-database interaction.
• Database provides user with views and these are
• Data abstraction
• Instances and schemas
• Data Independence
• Data Models
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction
• Database systems are made-up of complex data structures.
• To ease the user interaction with database, the developers hide internal
irrelevant details from users.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction –
Physical Level/ Internal Level
• The physical or the internal level schema describes how the data is
stored in the hardware.
• The physical level shows the data abstraction at the lowest level and it
has complex data structures.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction –
Logical Level/ Conceptual Level
• It is a level above the physical level. The data is stored in the form of the
entity set, entities, their data types, the relationship among the entity sets,
user operations performed to retrieve or modify the data and certain
constraints on the data.
• Describes what data are stored in database.
• Describes the relationship among the data
• Well adding constraints to the view of data adds the security. As users
are restricted to access some particular parts of the database.
• It is the developer and database administrator who operates at the
logical or the conceptual level.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction –
View Level/ User level/ External level
• It is the highest level of data abstraction and exhibits only a part of the
whole database. It exhibits the data in which the user is interested.
• The view level can describe many views of the same data.
• Here, the user retrieves the information using different application from
the database.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Abstraction
Example
Let’s say we are storing customer information in a customer table
•At physical level these records can be described as blocks of storage in
memory. These details are often hidden from the programmers.
•At the logical level these records can be described as fields and attributes along
with their data types, their relationship among each other can be logically
implemented. The programmers generally work at this level because they are
aware of such things about database systems.
•At view level, user just interact with system with the help of GUI and enter the
details at the screen, they are not aware of how the data is stored and what data
is stored; such details are hidden from them.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
INSTANCES AND SCHEMAS
• What is SCHEMA?
• Design of a database is called the schema.
• Schema is of three types:
• Physical schema : It is a database design described at the physical level
of abstraction
• Logical schema : It is a database design at the logical level of
abstraction
• View schema : A database may have several views at the view level
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
SCHEMAS
• Physical database schema:
• It describes how data will be stored in hard disc / secondary storage device.
• It describes the database design at physical level.
• The schema related to the actual storage of data and its form of storage like file, indices.
• Logical database schema:
• This schema define all the logical constraints that need to be applied on the data storage.
• It Defines table, views, and integrity constraint.
• Define relationship between table and keys applied.
• View Schema:
• It describes different views of database and sometime also called subschema.
Instances
• The data stored in database at a particular moment of time is called instance of
database.
• When information is inserted or deleted from the database then the database gets
changed. The collection of information at particular moment is called instances.
• Eg: lets say we have a single table student in the database, today the table has 100
records, so today the instance of the database has 100 records. Lets say we are going
to add another 100 records in this table by tomorrow so the instance of database
tomorrow will have 200 records in table. In short, at a particular moment the data
stored in database is called the instance, that changes over time when we add or
delete data from the database.
• Eg: Following is an instance of student database
RollNo Name Marks
10 AAA 45
DATA INDEPENDENCE
• Data independence defines the extent to which the data schema can be changed
at one level without modifying the data schema at the next level. Data
independence can be classified as shown below:
• Logical Data Independence
• the degree up to which the logical or conceptual schema can be changed
without modifying the external schema.
• Physical Data Independence
• the extent up to which the data schema can be changed at the physical or
internal level without modifying the data schema at logical and view level.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
TOPIC
Data Models
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Data Models
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Types of Data Models
There are several types of data models in DBMS:
1) Object based logical Models – Describe data at the conceptual and view levels.
– ER MODEL
– Object oriented Model
2)Record based logical Models –They also describe data at the conceptual and
view levels. These models specify logical structure of database with records, fields
and attributes.
- Relational Model
- Hierarchical Model
- Network Model
3)Physical Data Models – These models describe data at the lowest level of
abstraction. CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Entity-Relationship Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Entity-Relationship Model - Components
• Entities: Entity is a real-world thing. It can be a person, place, or even a
concept.
• Eg: Teachers, Students, Course, Building, Department, etc are some
of the entities of a School Management System.
• Attributes: An entity contains a real-world property called attribute. This
is the characteristics of that attribute.
• Eg: The entity teacher has the property like teacher id, salary, age,
etc.
• Relationship: Relationship tells how two attributes are related.
• Eg: Teacher works for a department.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Entity-Relationship Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Entity-Relationship Model - Features
1. Graphical Representation for Better Understanding:
2. ER Diagram:
3. Database Design:
This model helps the database designers to build the database and is widely
used in database design.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Entity-Relationship Model - Merits
• Simple:
• Conceptually ER Model is very easy to build. If we know the relationship
between the attributes and the entities we can easily build the ER Diagram for the
model.
• Effective Communication Tool:
• This model is used widely by the database designers for communicating their
ideas.
• Easy Conversion to any Model:
• This model maps well to the relational model and can be easily converted
relational model by converting the ER model to the table. This model can also be
converted to any other model like network model, hierarchical model etc.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Entity-Relationship Model - Demerits
• Hidden information:
Some information might be lost or hidden in the ER model. As it is a high-
level view so there are chances that some details of information might be hidden.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Object oriented Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Object oriented Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Object oriented Model
• Objects –
• An object is an abstraction of a real world entity or we can say it is an instance of class.
Objects encapsulates data and code into a single unit which provide data abstraction by
hiding the implementation details from the user.
• Eg: Instances of student, doctor, engineer in above figure.
• Attribute –
• An attribute describes the properties of object.
• Eg: Object is STUDENT and its attribute are Roll no, Branch, Setmarks() in the Student
class.
• Methods –
• Method represents the behavior of an object. Basically, it represents the real-world action.
• Eg: Finding a STUDENT marks in above figure as Setmarks().
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Object oriented Model
• Class –
• A class is a collection of similar objects with shared structure i.e. attributes and behavior
i.e. methods. An object is an instance of class.
• Eg: Person, Student, Doctor, Engineer in above figure.
• Inheritance –
• By using inheritance, new class can inherit the attributes and methods of the old class
i.e. base class.
• Eg: as classes Student, Doctor and Engineer are inherited from the base class Person.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Object oriented Model
Advantages of Object Oriented Data Model :
• Codes can be reused due to inheritance.
• Easily understandable.
• Cost of maintenance can be reduced due to reusability of attributes and
functions because of inheritance.
Disadvantages of Object Oriented Data Model :
• It is not properly developed so not accepted by users easily
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Relational Model
• Relational Model (RM) represents the database as a collection of
relations.
• A relation is nothing but a table of values. Every row in the table
represents a collection of related data values.
• These rows in the table denote a real-world entity or relationship.
• The table name and column names are helpful to interpret the meaning
of values in each row. The data are represented as a set of relations.
• In the relational model, data are stored as tables. However, the
physical storage of the data is independent of the way the data are
logically organized.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Relational Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Hierarchical Model
• Hierarchical model organises data into a tree-like-structure, with a single
root, to which all the other data is linked.
• The hierarchy starts from the Root data, and expands like a tree, adding
child nodes to the parent nodes.
• In this model, a child node will only have a single parent node.
• This model efficiently describes many real-world relationships like index
of a book, recipes etc.
• Eg: one department can have many courses, many professors.,
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Hierarchical Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Network Model
• The network model was created to represent complex data
relationships more effectively when compared to hierarchical models,
to improve database performance and standards.
• In this model data is organised more like a graph, and are allowed to
have more than one parent node.
• In this database model data is more related as more relationships are
established in this database model. Also, as the data is more related,
hence accessing the data is also easier and fast. This database model
was used to map many-to-many data relationships.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Network Model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Network Model - Features
• Ability to Merge Relationships − In this model, because of more relationships the
data is more related. It has an ability to manage one-to-one relationships as well
as many-to-many relationships.
• Many paths − There can be more than one path to the same record because of
more relationships. It makes data access fast and simple.
• Circular Linked List − The operations in this model are done with the help of the
circular linked list. The current position is maintained with the help of a program
and navigates through the records based on relationships.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Physical data model
• Physical data model represent the model where it describes how
data are stored in computer memory, how they are scattered and
ordered in the memory, and how they would be retrieved from
memory.
• Basically physical data model represents the data at data layer or
internal layer. It represents each table, their columns and
specifications, constraints like primary key, foreign key etc.
• It basically represents how each tables are built and related to
each other in DB.
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Physical data model
CS3492/DBMS/IICSE/IVSEM/KG-KiTE