Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 40

KGiSL Institute of Technology

(Approved by AICTE, New Delhi; Affiliated to Anna University, Chennai)


Recognized by UGC, Accredited by NBA (IT)
365, KGiSL Campus, Thudiyalur Road, Saravanampatti, Coimbatore – 641035.

Department of Computer Science and Engineering

Name of the Faculty : Ms. Aruna T N

Subject Name & Code : CS3492/ Database Management Systems

Branch & Department : Computer Science and Engineering

Year & Semester : II / IV

CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Course Outcome

CO 1 Demonstrate fundamentals of Data models and Relational


databases - K3 LEVEL

CS3492/DBMS/IICSE/IVSEM/KG-KiTE
Syllabus
UNIT I - RELATIONAL DATABASES

Purpose of Database System – Views of data – Data Models –


Database System Architecture – Introduction to relational
databases – Relational Model – Keys – Relational Algebra – SQL
fundamentals – Advanced SQL features – Embedded SQL–
Dynamic SQL

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.

• This process of hiding irrelevant details from user is called data


abstraction.

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.

• It also describes how the data can be accessed.

• The physical level shows the data abstraction at the lowest level and it
has complex data structures.

• Only the database administrator operates at this level.

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.

• It can provide the access to only part of the database.

• 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

• Eg: The schema for the student record can be,


RollNo Name Marks
CS3492/DBMS/IICSE/IVSEM/KG-KiTE
SCHEMAS
• The diagram only shows the design of the database it doesn’t show the data
present in those tables.
• Schema is only a structural view(design) of a database.

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

• Data models define how the logical structure of a database is modelled.


• Data Models are fundamental entities to introduce abstraction in a DBMS.
• Data models define how data is connected to each other and how they
are processed and stored inside the system.

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

• It is a high-level data model diagram


• The real-world problem in the pictorial form to make it easy for the
stakeholders to understand.

• It is also very easy for the developers to understand the system by


just looking at the ER diagram

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:

It is very easy and simple to understand so it can be used by the developers to


communicate with the stakeholders.

2. ER Diagram:

ER diagram is used as a visual tool for representing the model.

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

• No industry standard for notation:


There is no industry standard for developing an ER model. So one
developer might use notations which are not understood by other developers.

• 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

• To represent the complex real world problems there was a need


for a data model that is closely related to real world.
• Object Oriented Data Model represents the real world problems
easily.

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

You might also like