DBMS-1
DBMS-1
MANAGEMENT
SCIENCE
UNIT-I
II-CSD R22
Unit-1
Database System Applications:
A Historical Perspective
File Systems versus a DBMS
the Data Model
Levels of Abstraction in a DBMS
Data Independence
Structure of a DBM
Introduction to Database Design:
Database Design and ER Diagrams
Entities
Attributes
and Entity Sets
Relationships and Relationship Sets
Additional Features of the ER Model
Conceptual Design With the ER Model
History of database management systems
● The first DBMS was developed in the early 1960s when Charles Bachman created a navigational(network) DBMS known as the Integrated Data
Store.
● In 1968, IBM developed Information Management System or IMS, a hierarchical DBMS designed for IBM mainframes that's still used today by
many large organizations.
● But the DBMS market changed forever as the relational model for data gained popularity. Introduced by Edgar Codd of IBM in 1970 in his
seminal paper "A Relational Model of Data for Large Shared Data Banks," the RDBMS soon became the industry standard. The first RDBMS was
Ingres, developed at the University of California, Berkeley by a team led by Michael Stonebraker in the mid-1970s.
● IBM was working on its System R project to develop an RDBMS.
● In 1979, the first successful commercial RDBMS, Oracle, was released, followed a few years later by IBM's Db2, Sybase SQL Server and many
others.
● In the 1990s, as object-oriented programming (OOP) became popular, several OOP database systems came to market, but they never gained
significant market share.
● Later in the 1990s, the term NoSQL was coined.
● Over the next decade, several types of new non-relational DBMS products -- including key-value, graph, document and wide-column store --
were grouped into the NoSQL category.
● Today, the DBMS market is dominated by RDBMSes, but NewSQL and NoSQL database systems continue to grow in popularity.
File Systems versus a DBMS
The file system is basically a way of arranging the files in a storage medium like a hard disk. The file
system organizes the files and helps in the retrieval of files when they are required. File systems consist of
different files which are grouped into directories. The directories further contain other folders and files. The
file system performs basic operations like management, file naming, giving access rules, etc.
Database Management System is basically software that manages the collection of related data. It is used
for storing data and retrieving the data effectively when it is needed. It also provides proper security
measures for protecting the data from unauthorized access. In Database Management System the data can
be fetched by SQL queries and relational algebra. It also provides mechanisms for data recovery and data
backup.
File System DBMS System
Parameter File System DBMS
Definition A file system is a method of storing and organizing data into Software that stores, manages, and retrieves data efficiently.
files in a hierarchical order.
Data Organization Organizes the data in a hierarchical directory. Organizes the data in a pre-defined structure.
Data Retrieval It searches entire directories and files to find any specified data. Uses SQL queries to retrieve the data.
Data Manipulation Very limited options are available such as renaming and Have advanced functionality to manipulate the data, such as
copying. updating, deleting, and inserting the records.
Scalability Limited scalability as the size and complexity increase. Provide scalability as it can handle extremely large amounts
of data.
Security Provide basic file permission for controlling access to files and Provide robust security measures for controlling access to
directories. data.
Backup & Recovery Require manual backups & recovery of files and data Provide backup & recovery mechanisms for ensuring data
availability and preventing data loss.
Uses Cases Suitable for simple data storage and retrieval tasks. Suitable for complex data management tasks such as
e-commerce, finance etc.
Database Schema Definition
A database schema refers to the logical and visual configuration
of the entire relational database. The database objects are often
grouped and displayed as tables, functions, and relations. A
schema describes the organization and storage of data in a Details of a Customer
database and defines the relationship between various tables. A
database schema includes descriptive details of the database that
can be depicted through schema diagrams.
Or
A database schema is a logical representation of data that
shows how the data in a database should be stored logically. It
shows how the data is organized and the relationship between the
tables.
Schema of Customer
Types of Database Schemas
There are 3 types of database schema:
Physical Database Schema
● A Physical schema defines, how the data or information is stored physically in the storage
systems in the form of files & indices. This is the actual code or syntax needed to create the
structure of a database, we can say that when we design a database at a physical level, it’s
called physical schema.
Logical Database Schema
● A logical database schema defines all the logical constraints that need to be applied to the
stored data, and also describes tables, views, entity relationships, and integrity constraints.
● The Logical schema describes how the data is stored in the form of tables & how the attributes of a
table are connected.
●Using ER modelling the relationship between the components of the data is maintained.
● As per your application's requirement, you can use a database model to define your database.
● The database model sets the rule, relationships, constraints, etc. to define how data is stored in the database.
● It's like creating a blueprint of your Database.
● There are different types of Database models and each one has its own set of features.
● You can define how you want to structure the application data using a database model.
1. Hierarchical Model
2. Network Model
3. Entity-relationship Model
4. Relational Model
5. Object-oriented Model
6. NoSQL Model
7. Graph Model
Hierarchical Model
● The hierarchical database model organizes 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 the index of a book, etc.
● IBM's Information Management System (IMS) is based on this model.
● Data is organized into a tree-like structure with a one-to-many relationship between two different types of data,
for example, one department can have many courses, many teachers, and of course many students(like shown in
the diagram below).
Here are a few points to mark the advantages and disadvantages of the Hierarchical database model:
1. Because it has one-to-many relationships between different types of data so it is easier and fast to fetch the data.
2. But the Hierarchical model is less flexible.
3. And it doesn't support many-to-many relationships.
Network Model
● In this database model, relationships are created by dividing objects of interest into entities and their characteristics into
attributes.
● Different entities are related using relationships.
● ER Models are defined to represent the relationships in pictorial form to make it easier for different stakeholders to
understand.
● This model is good to design a database, which can then be turned into tables in a relational model (explained below).
● Let's take an example, If we have to design a School Database, then the Student will be an entity with attributes name,
age, address, etc. As an Address is generally complex, it can be another entity with attributes street, pincode, city, etc, and
there will be a relationship between them.
● Relationships can also be of different types. You can learn about ER Diagrams in detail if you want to learn about entities
and relationships.
● In this model, data is organized in two-dimensional tables and the relationship is maintained by storing a common
field.
● This model was introduced by E.F Codd in 1970, and since then it has been the most widely used database model.
● The basic structure of data in the relational model is tables. All the information related to a particular type is
stored in rows of that table.
● Hence, tables are also known as relations in the relational model.
● You can design tables, normalize them to reduce data redundancy, and use Structured Query language or SQL to
access data from the tables.
● Some of the most popular databases are based on this database model. For example, Oracle, MySQL, etc.
Data abstraction helps to keep data secure from unauthorized access and it hides all the
implementation details.
It refers to the characteristic of being able to modify the physical schema without any alterations to the conceptual or
logical schema, done for optimization purposes, e.g., the Conceptual structure of the database would not be affected
by any change in storage size of the database system server.
Changing from sequential to random access files is one such example. These alterations or modifications to the
physical structure may include:
● Utilizing new storage devices.
● Modifying data structures used for storage.
● Altering indexes or using alternative file organization techniques etc.
It refers characteristic of being able to modify the logical schema without affecting the external schema or
application program. The user view of the data would not be affected by any changes to the conceptual view of the
data. These changes may include insertion or deletion of attributes, altering table structures entities or relationships
to the logical schema, etc.
Structure of Database Management System
Database Management System (DBMS) is software that allows access to data stored in a database
and provides an easy and effective method of –
● Defining the information.
● Storing the information.
● Manipulating the information.
● Protecting the information from system crashes or data theft.
● Differentiating access permissions for different users.
Note: Structure of Database Management System is also referred to as Overall System Structure or
Database Architecture but it is different from the tier architecture of Database.
The database system is divided into three components:
1. Query Processor,
2. Storage Manager, and
3. Disk Storage.
Query Processor: It interprets the requests (queries) received from end user via an application program into
instructions. It also executes the user request which is received from the DML compiler.
Query Processor contains the following components –
Query Processor Components :
• DML Pre-compiler : It translates DML statements in a query language into low level instructions that
query evaluation engine understands. It also attempts to transform user's request into an equivalent
but more efficient form.
• Embedded DML Pre-compiler : It converts DML statements embedded in an application program to
normal procedure calls in the host language. The Pre-compiler must interact with the DML compiler to
generate the appropriate code.
• DDL Interpreter : It interprets the DDL statements and records them in a set of tables containing
meta data or data dictionary.
• Query Evaluation Engine : It executes low-level instructions generated by the DML compiler.
2. Storage Manager Components :
They provide the interface between the low-level data stored in the database and application programs and
queries submitted to the system.
Authorization and Integrity Manager : It tests for the satisfaction of integrity constraints checks the
authority of users to access data.
Transaction Manager : It ensures that the database remains in a consistent state despite the system failures
and that concurrent transaction execution proceeds without conflicting.
File Manager : It manages the allocation of space on disk storage and the data structures used to represent
information stored on disk.
Buffer Manager : It is responsible for fetching data from disk storage into main memory and deciding what
data to cache in memory.
Disk Storage :
Following data structures are required as a part of the physical system implementation.
Data Files : It stores the database.
Data Dictionary : It stores metadata (data about data) about the structure of the
database.
Indices : Provide fast access to data items that hold particular values.
Statistical Data : It stores statistical information about the data in the database. This
information is used by query processor to select efficient ways to execute query.
Structured Query Language (SQL), as we all know, is the database language by which
we can perform certain operations on the existing database, and we can also use this
language to create a database. SQL uses certain commands like CREATE, DROP, INSERT,
etc. to carry out the required tasks.
SQL commands are like instructions to a table. It is used to interact with the database with
some operations. It is also used to perform specific tasks, functions, and queries of data.
SQL can perform various tasks like creating a table, adding data to tables, dropping the
table, modifying the table, set permission for users.
DDL (Data Definition Language)
DDL or Data Definition Language actually consists of the SQL commands that can be used to define the
database schema. It simply deals with descriptions of the database schema and is used to create and
modify the structure of database objects in the database.
DDL is a set of SQL commands used to create, modify, and delete database structures but not data. These
commands are normally not used by a general user, who should be accessing the database via an
application.
DML(Data Manipulation Language)
The SQL commands that deal with the manipulation of data present in the
database belong to DML or Data Manipulation Language and this includes most of
the SQL statements.
It is the component of the SQL statement that controls access to data and to the
database. Basically, DCL statements are grouped with DML statements.
Database Design and ER Diagrams:
Peter Chen developed the ER diagram in 1976 .The ER model was created to provide a simple
and understandable model for representing the structure and logic of databases. It has since
evolved into variations such as the Enhanced ER Model and the Object Relationship Model.
The Entity Relational Model is a model for identifying entities to be represented in the database
and representation of how those entities are related. The ER data model specifies enterprise
schema that represents the overall logical structure of a database graphically.
The Entity Relationship Diagram explains the relationship among the entities present in the
database. ER models are used to model real-world objects like a person, a car, or a company and
the relation between these real-world objects. In short, the ER Diagram is the structural format
of the database.
Why Use ER Diagrams In DBMS?
● ER diagrams are used to represent the E-R model in a database, which makes them
easy to convert into relations (tables).
● ER diagrams provide the purpose of real-world modeling of objects which makes
them intently useful.
● ER diagrams require no technical knowledge and no hardware support.
● These diagrams are very easy to understand and easy to create even for a naive user.
● It gives a standard solution for visualizing the data logically.
Symbols Used in ER Model
ER Model is used to model the logical view of the system from a data perspective which consists
of these symbols:
● Rectangles: Rectangles represent Entities in the ER Model.
● Ellipses: Ellipses represent Attributes in the ER Model.
● Diamond: Diamonds represent Relationships among Entities.
● Lines: Lines represent attributes to entities and entity sets with other relationship types.
● Double Ellipse: Double Ellipses represent Multi-Valued Attributes.
● Double Rectangle: Double Rectangle represents a Weak Entity.
Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among Entities in a
Database System.
Entity
An Entity may be an object with a physical existence – a particular person, car, house, or employee – or it may
be an object with a conceptual existence – a company, a job, or a university course.
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on other Entity in
the Schema. It has a primary key, that helps in identifying it uniquely, and it is represented by a rectangle.
These are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the entity set. But some entity type
exists for which key attributes can’t be defined. These are called Weak Entity types.
For Example, A company may store the information of dependents (Parents, Children, Spouse)
of an Employee. But the dependents can’t exist without the employee. So Dependent will be a
Weak Entity Type and Employee will be Identifying Entity type for Dependent, which means it
is Strong Entity Type.
Attributes
Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB, Age,
Address, and Mobile_No are the attributes that define entity type Student. In ER diagram, the
attribute is represented by an oval.
1. Key Attribute
2. Composite Attribute
3. Multivalued Attribute
4. Derived Attribute
Key Attribute
The attribute which uniquely identifies each entity in the entity set is
called the key attribute. For example, Roll_No will be unique for each
student. In ER diagram, the key attribute is represented by an oval with
underlying lines.
Composite Attribute
An attribute composed of many other attributes is called a composite
attribute. For example, the Address attribute of the student Entity type
consists of Street, City, State, and Country. In ER diagram, the composite
attribute is represented by an oval comprising of ovals.
Multivalued Attribute
An attribute consisting of more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In ER
diagram, a multivalued attribute is represented by a double oval.
Derived Attribute
An attribute that can be derived from other attributes of the entity type
is known as a derived attribute. e.g.; Age (can be derived from DOB). In
ER diagram, the derived attribute is represented by a dashed oval.
The Complete Entity Type Student with its Attributes can be represented as:
Entity Set:
An Entity is an object of Entity
Type and a set of all entities is
called an entity set. For Example,
E1 is an entity having Entity Type
Student and the set of all students is
called Entity Set. In ER diagram,
Entity Type is represented as:
Relationship Type
A Relationship Type represents the association between entity types. For
example, ‘Enrolled in’ is a relationship type that exists between entity type
Student and Course. In ER diagram, the relationship type is represented by a
diamond and connecting the entities with lines.
Relationship Set
A set of relationships of the same type is known as a relationship set. The following
relationship set depicts S1 as enrolled in C2, S2 as enrolled in C1, and S3 as
registered in C3.
1. Unary Relationship: When there is only ONE entity set participating in a relation, the
relationship is called a unary relationship. For example, one person is married to only one
person.
2. Binary Relationship: When there are TWO entities set participating in a relationship, the
relationship is called a binary relationship. For example, a Student is enrolled in a Course.
3.Ternary Relationship: When there are n entities set participating in a relation, the
relationship is called an n-ary relationship.
Cardinality
The number of times an entity of an entity set participates in a relationship set is known as
cardinality. Cardinality can be of different types:
1. One-to-One: When each entity in each entity set can take part only once in the relationship, the
cardinality is one-to-one. Let us assume that a male can marry one female and a female can marry
one male. So the relationship will be one-to-one.
the total number of tables that can be used in this is 2.
Using Sets, it can be represented as:
One-to-Many (1:N) Relationship
price battery
Electronic Device
Is
a
Mobile Laptop
mobile_id laptop_id
Specialization
In specialization, an entity is divided into sub-entities based on its
characteristics. It is a top-down approach where the higher-level entity is
specialized into two or more lower-level entities.
Emp_
E_SA
name
L
EMPLOYEE
I Emp_n
ame E_S
s AL
a TESTER
DEVELOP TES_
TESTER TYPE
ER
TES_
TYPE
Aggregation
In aggregation, the relation between two entities is treated as a single
entity. In aggregation, relationship with its corresponding entities is
aggregated into a higher level entity.
Conceptual Modeling using the Entity-Relationship Model
Contents
• Basic concepts: entities and entity types, attributes and keys, relationships and relationship
types
• Design choices
[Step 3] Identify and associate attributes with entity and relationship types
• Primary keys allow entity types and relationship types to be expressed uniformly as tables.
• For each entity and relationship type, a unique table can be derived which is assigned the
name of the corresponding entity or relationship type.
• Each table has a number of columns that correspond to the attributes and which have
unique names. An attribute of a table has the same domain as the attribute in the ER schema.
• Translating an ER schema into a collection of tables is the basis for deriving a relational
database schema from an ER diagram.