ME DBMS Unit1 Final
ME DBMS Unit1 Final
ME DBMS Unit1 Final
E.g. transfer of funds from one account to another should either complete or not happen at all
Security problems
CHARACTERISTICS OF DBMS
Self-describing nature of DB
The database system contains data and definition of the database. The data definition is stored on the system catalog, which contains the structure of the files, data type for each data item
and various constraints on the data. The information stored in the catalog is called meta data
In object, oriented DB system the operation becomes a part of DB system. This operation consists of two parts called interface and implementation. The interface includes operation name
and data type and implementation represents method of the operation. Thus, the method or the implementation can be changed without affecting the interface is called as program-
operation-independence.
• Here, the hardware in a database environment means the computers and computer peripherals that are being
used to manage a database, and the software means the whole thing right from the operating system (OS) to the
application programs that include database management software like M.S. Access or SQL Server.
• Again the people in a database environment include those people who administrate and use the system. The
techniques are the rules, concepts, and instructions given to both the people and the software along with the
data with the group of facts and information positioned within the database environment.
A simplified database environment
Database system concepts and architecture
DATABASE SYSTEM CONCEPTS
• Data models:
• Data model is a collection of concepts that can be used to describe the structure of data base
• Conceptual DM provides concepts that explains the different ways to perceive data and uses the concepts such
as entities, attributes, and relationships.
• Attributes represent the properties or the further description of the entity. For example employee name or salary.
• Relationship: represents the interaction among the entities. For example work-on relationship between employee
and project.
• This will provide the concept of how the data is stored in the computer
• The storage format is also specified in this Data Model such as, record format, record
ordering and access path.
• It provides the concepts that may be understood by end users but that are not too far removed
from the way data is stored in the computer.
• Instance or occurrences:
The data in the database at a particular moment is called database state or extension, which
is the current set of instances. At the initial state of the database, the database state is said to
be empty.
Data model – a collection of concepts that can be used to describe the structure of DB.
Network Model
Entity-Relationship Model
Relational Model
1.Oracle --Oracle Database is a relational database management system (RDBMS) developed by Oracle Corporation.
2.MySQL --MySQL is a free and open-source relational database management system (RDBMS)It was developed by Swedish company MySQL AB, which was later acquired by
Oracle Corporation.
3.SQL Server --SQL Server is a relational database management system (RDBMS) developed by Microsoft Corporation.
4.PostgreSQL --PostgreSQL is a free and open-source relational database management system (RDBMS) it was developed by active community of developers
5.IBM DB2 --IBM DB2 is a relational database management system (RDBMS) developed and marketed by IBM.
6.Microsoft Access --Microsoft Access is a relational database management system (RDBMS) that is part of the Microsoft Office suite of applications.
7.SQLite --SQLite is a popular open-source relational database management system (RDBMS) that is widely used in embedded systems, mobile devices, and desktop
applications.
8.MariaDB --MariaDB is an open-source relational database management system (RDBMS) that is a fork of the popular MySQL database system. developed by Oracle
Corporation.
9.Informix --nformix is a relational database management system (RDBMS) that is used for transaction processing and data warehousing developed by IBM
10.Azure SQL --Azure SQL is a cloud-based relational database service offered by Microsoft as part of their Azure cloud computing platform
Three schema Architecture
The three schema architecture is also called ANSI/SPARC architecture or three-
level architecture.
The three schema architecture is also used to separate the user applications and
physical database.
The three schema architecture contains three levels. It breaks the database down
into three different categories.
The Three-Schema Architecture
The above diagram:
Mapping is used to transform the request and response between various database levels of
architecture.
Mapping is not good for small DBMS because it takes more time.
In External / Conceptual mapping, it is necessary to transform the request from the external
level to the conceptual schema.
In Conceptual / Internal mapping, DBMS transforms the request from the conceptual to the
internal level.
The schemas are defined at three levels
Internal level:
It has an internal scheme, which describes the physical storage structure of the database by
means of different data structures link lists, queues, stacks, etc.
The three schemas are only descriptions of the database. The data is actually stored in the
database.
If a particular user wants to retrieve data, he has to place a request at the external level.
The DBMS must transform this request specified on the external schema into a request
against the conceptual schema and then into a request on the internal schema for processing
over the stored database.
Hence, the retrieved data is reformatted and sent back to the user through the external view.
Thus, the processes of transforming requests and results between levels are called Mappings.
DATA INDEPENDENCE:
It is the capacity to change the schema at one level of a database system without having to
change at the next higher level. There are two types.
1. Logical data independence
2. Physical data independence
It is the capacity to change the conceptual schema without having to change the external
schema. Only the mappings between conceptual and external schema need to be changed.
It is the capacity to change the internal schema without having to change the conceptual
schema. Only the mappings between conceptual and internal schema need to be changed.
Data modeling using entity Relationship(ER) model
ENTITY- RELATIONSHIP MODEL (E-R MODEL)
The entity relationship model is a high-level conceptual model that is useful for end users.
An ER model describes data as
Entities
Attributes
Relationships
Weak entity:
Entity types that do not have key attributes of their own are called weak entities.
Example:
Name, age
Strong entity:
•
Attributes:
Attributes are the properties that describe an entity . For example an employee
entity is described by the employee’s name, age, address, and salary.
A particular entity will have a value for each of its attributes.
Types of attributes:
• composite versus simple:
Key attributes:
An entity type usually has an attribute whose values are distinct for each individual entity in
the collection. Such an attribute is called a key attribute and its values can be used to identify
each entity uniquely.
Example:
Ssn of an employee entity, regno of a student entity, rollno of a student, dno of a department entity.
An entity types can have more than one key attribute . For student entity regno, rollno both are key attributes
that uniquely identifies a student.
Relationships:
Whenever an attribute of one entity type refers to another entity type, some relationship exists
between entities.
Degree of relationship:
The degree of a relationship type is the number of participating entity types. In the works_for,
relationship that associates the employee and department entity the degree of relationship is
two. If the degree is, it is called a binary relationship, and one of degree three is called ternary.
Constraints on relationships:
•Relationship types usually have certain constraints that limit the possible combinations of
entities that may participate in the corresponding relationship set.
Total participation:
Partial participation:
Relationships can have attributes: example: the WORKS_ON relationship, which relates
employee and project, can have hours attribute to record the number of hours per week that
Today the complexity of the data is increasing so it becomes more and more difficult to use the traditional ER
model for database modeling.
To reduce this complexity of modeling we have to make improvements or enhancements to the existing ER
model to make it able to handle the complex application in a better way.
EER is a high-level data model that incorporates the extensions to the original ER model
Generalization
Specialization
Aggregation
Features of EER Model
It is a Bottom up process i.e. consider we have 3 sub entities Car, Truck and Motorcycle.
Now these three entities can be generalized into one super class named as Vehicle.
Specialization
Specialization is a process of identifying subsets of an entity that share
some different characteristic.
It is a top down approach in which one entity is broken down into low
level entity.
It is used to uniquely identify any record or row of data from the table. It is also used to
establish and identify relationships between tables.
For example, ID is used as a key in the Student table because it is unique for each student.
In the PERSON table, passport_number, license_number, SSN are keys since they are unique
for each person.
RELATIONAL MODEL CONSTRAINTS:
Constraints are various restrictions or conditions on data that can be specified on a relational
database. These include
Domain constraints
Key constraints
Domain constraints specify that the value of each attribute A must be an atomic value from the
domain dom(A).
Hence the composite and multi valued attributes are not allowed.
Multi valued attributes must be represented by separate relations, and composite attributes are
represented only by their simple component attributes.
KEY CONSTRAINTS
No two tuples can have the same combination of values for all their attributes.
There must be at least one attribute, which identifies each tuple uniquely.
A relation may have more than one key and each of the keys is called a candidate key and any
one of the candidate keys is designated as a primary key.
ENTITY INTEGRITY CONSTRAINTS
The entity integrity constraint states that no primary key value can be null.
This is because the primary key value is used to identify individual tuples in a relation;
having null values for the primary key implies that we cannot identify some tuples.
The Referential integrity constraint is specified between two relations and is used to maintain
the consistency among tuples of the relations.
To define referential integrity more formally, we first define the concept of a foreign key.
The foreign key specifies referential integrity constraints between the two relation schemas
R1 and R2.
Foreign key:
In our example, SSN is the primary key of employee relation and DNO is the primary key of
department relation.
The employee relation needs to refer the department relation hence we designate DNO as
foreign key of employee.
The relational model for employee database is given below in that the primary keys are
underlined and referential integrity constraints are represented by, drawing directed arc
from each foreign key to the relation it references.
An entity can contain multiple keys, as we saw in the PERSON table. The key which is most
suitable from those lists becomes a primary key.
2. Candidate key
`
A candidate key is an attribute or set of attributes that can uniquely identify a tuple.
Except for the primary key, the remaining attributes are considered a candidate key.
A super key is an attribute set that can uniquely identify a tuple. A super key is a superset of
a candidate key.
For example:
In the above EMPLOYEE table, for (EMPLOEE_ID, EMPLOYEE_NAME), the name of two employees can be the same, but their
EMPLYEE_ID can't be the same. Hence, this combination can also be a key .
4. Foreign key
`
Foreign keys are the column of the table used to point to the primary key of another table.
Every employee works in a specific department in a company, and employee and department are two different entities.
That's why we link these two tables through the primary key of one table.
We add the primary key of the DEPARTMENT table, Department_Id, as a new attribute in the EMPLOYEE table.
In the EMPLOYEE table, Department_Id is the foreign key, and both the tables are related.
5. Alternate key
`
There may be one or more attributes or a combination of attributes that uniquely identify each tuple in a
relation.
These attributes or combinations of the attributes are called the candidate keys.
One key is chosen as the primary key from these candidate keys, and the remaining candidate key, if it exists,
is termed the alternate key.
For example, employee relation has two attributes, Employee_Id and PAN_No, that act as candidate keys. In this relation, Employee_Id is
chosen as the primary key, so the other candidate key, PAN_No, acts as the Alternate key.
6. Composite key
`
• Whenever a primary key consists of more than one attribute, it is known as a composite key. This key is also
known as Concatenated Key.
7. Artificial key
`
• The key created using arbitrarily assigned data is known as artificial key.
• These keys are created when a primary key is large and complex and has no relationship with many other
relations.
• The data values of the artificial keys are usually numbered in serial order.
RELATIONAL MODEL FOR COMPANY DATABASE
Referential integrity constraints displayed on the COMPANY relational database schema.
Naming Conventions
Naming Conventions
• Naming conventions are a set of guideline that make strong foundations for such a consistent system.
These guidelines ensure that the names of database entities are readable, easy to use in queries and do
not collide with names of other defined entities or keywords.
• NamingTables :
Tables represent a group/set of some entity that is usually a real-world object like an employee or
consequences of that entity like a project. Tables names are like nouns. Different teams of developers
follow different practices while naming their tables but some fundamentals are the key to efficiency.
There are following steps for the Naming table are as follows.
• Table names should be descriptive. If you are designing a table to store the data about customers in a
grocery shop then the table can be named “Customer” or “Customers” based on your preference
• NamingColumns :
Columns are different than tables as they can mean more than just a real-world entity. Columns
are the attributes that define a real-world entity. Columns may define the departure time of a train
or the distance of a planet from the sun, or simply someone’s name.
• Naming Primary Keys :
• Primary keys serve as the unique identifier for your table, thus it is important to be careful while naming them.
If several different tables with different uses have the same name for their respective primary key then it
would be very confusing.
• Make sure that instead of naming a primary key representing an identity number as ID, use domain-specific
names like StudentID or ID_Student.
• You can also use suffixes or prefixes with your primary keys to making them stand out from the general
column naming. For example, Coordinates_PK or PK_Coordinates.
• Naming Foreign Keys :
• Foreign keys are used as a bridge between two tables, and sometimes among more tables.
Thus, it is good to name your foreign key with the same name consistently throughout the
database to avoid any confusion.
• Similar to primary keys, you can add prefix or suffix to a foreign key name,
like RoomNo_fk or FK_RoomNo.
• At the end of the day, no one is going to force you to follow these conventions while
creating a database. But following even some of these will make your database better for
you as well as anyone else who might work on it in the future.
THE OBJECT ORIENTED DATABASES – INTRODUCTION
INTRODUCTION
• An object oriented database is a collection of objects defined by an object
oriented data model.
• An object oriented database can extend the existence of objects so that they are
stored permanently.
• Therefore, the objects persist beyond program termination and can be retrieved
later and shared by other programs
The Object oriented databases
An object-oriented database (OOD) is a database system that can work with complex
data objects — that is, objects that mirror those used in object-oriented programming
languages. In object-oriented programming (OOP), everything is an object.
• Object Database Definition
• Objects are the basic building block and an instance of a class, where the type is
either built-in or user-defined.
• Pointers help access elements of an object database and establish relations between
objects.
• The main characteristic of objects in OODBMS is the possibility of user-
constructed types. An object created in a project or application saves into a
database as is.
• Object-oriented databases directly deal with data as complete objects. All the
information comes in one instantly available object package instead of multiple
tables.
• For example, a parent class called Vehicle will have child classes Car and Bike. Both child
classes inherit information from the parent class and extend the parent class with new information depending
• Encapsulation is the ability to group data and mechanisms into a single object to provide
access protection. Through this process, pieces of information and details of how an object
works are hidden, resulting in data and function security. Classes interact with each other
through methods without the need to know how particular methods work.
• Abstraction
• Introduction:
• RDBMS stands for Relational Database management system.
• It is relational model in which data is stored in multiple tables where tables are
related to each other using primary keys and foreign keys and indexes.
• RDBMS uses database normalization techniques to avoid redundancy in tables.
It helps to fetch data faster using SQL query.
• It is widely used by enterprises and software developers to store large amount
of complex data.
• Examples: SQL server, Oracle, MySQL, MariaDB, SQLite
• Benefits or advantages of RDBMS
• SQL stands for Structured Query Language. Which is based on relational algebra and
schema is fixed in this which means data is stored in the form of columns and tables.
• SQL follows ACID properties which means Atomicity, Consistency, Isolation, and
Durability are maintained.
The data and data relationship is stored together in a single entity known as an object in the
• This approach allows for a more natural and intuitive representation of data, making it easier
Objects
Classes
Inheritance
Encapsulation
Polymorphism
Association
Aggregation and Composition
• Objects: Objects are instances of classes and represent individual entities or
concepts in the data model. Each object has attributes (also called properties or
fields) that describe its characteristics and methods (functions) that define its
behavior.
• Classes: Classes are blueprints or templates that define the structure and
behavior of objects. They specify what attributes an object of that class can
have and what methods can be called on those objects. Classes can inherit
attributes and methods from other classes through inheritance.
• Inheritance: Inheritance is a fundamental concept in OOP that allows one
class to inherit attributes and methods from another class. This enables the
creation of hierarchies and specialization of classes. Subclasses inherit
properties and behaviors from their parent classes and can also add new
attributes and methods or override existing ones.
• Some programming languages, such as Java and C++, are designed with built-in
support for OOP, making it easier to implement object-oriented data models in
software applications.
•
Persistence – Issues in OODBMS
Persistence –in OODBMS
Persistent objects are stored permanently in the secondary storage of object-oriented databases. These
persistent data and objects are shared across various applications and programs.
There are two methods that the OODBMS uses to access persistent objects, virtual memory address pointers,
and hash tables. A persistent object will always be ready to be invoked, and its state can and will be preserved
and survive any kind of system failure. Remember, persistent objects are stored on disk and transient objects
exist in RAM memory. In an OODBMS, an object may traverse between states.
Persistent means that the object has been saved to the database whereas transient means that it hasn't been
saved yet. So for example when you get an entity from a repository, that entity is persistent. When you create
a new entity, it is transient until persisted.
Object Oriented Database Management System Manifesto
Advantages and Disadvantages of OODBMS
Object Database
• Object Database is referred to as Object-oriented database (OODB) and the
database system is referred to as Object-oriented database management
system (ODBMS/OODBMS)
• ODBMS is the data model in which data is stored in form of objects, which are
instances of classes.
123
RDBMS and OODBMS
BASIS RDBMS OODBMS
Stands for Relational Database
Long Form Stands for Object Oriented Database Management System
Management System
Data Complexity Handles comparatively simpler data Handles larger and complex data than RDBMS
Entity type refers to the collection of entity Class describes a group of objects that have common
Grouping
that share a common definition relationships, behaviors, and also have similar properties
Data Handling RDBMS stores only data Stores data as well as methods to use it
A Primary key distinctively identifies an An object identifier (OID) is an unambiguous, long-term name for
Key
object in a table any type of object or entity
124
Object Database
Reasons for creation of Object Oriented Databases
•Need for more complex applications
•Need for additional data modeling features
•Increased use of object-oriented programming languages
125
What Is An Object In DBMS
• A database object is any defined object in a database that is used to store or reference
data . Anything which we make from create command is known as Database Object.
• It can be used to hold and manipulate the data. Some of the examples of database
objects are : view, sequence, indexes, etc.
126
Components of Object-Oriented Data Model
• Objects – User defined complex data types
• An object has structure or state (variables)
and methods (behavior/operations)
An object is described by four characteristics
• Identifier: a system-wide unique id for an
object
• Name: an object may also have a unique
name in DB (optional)
• Lifetime: determines if the object is
persistent or transient
• Structure: Construction of objects using
type constructors
127
Components of ODBMS
• There are three major components
1.Object structure
2.Object classes
3.Object identity
128
Components of ODBMS
Object Structure
•The structure of an object refers to the properties that an object is
made up of. These properties of an object are referred to as an
attribute
•Thus, an object is a real-world entity with certain attributes that
makes up the object structure
•Also, an object encapsulates the data code into a single unit which in
turn provides data abstraction by hiding the implementation details
from the user
129
Components of ODBMS
Object Structure
•The object structure is further composed of three types of components: Messages,
Methods, and Variables
• Messages
• A message provides an interface or acts as a communication medium between an
object and the outside world
• A message can be of two types:
• Read-only message: If the invoked method does not change the value of a variable,
then the invoking message is said to be a read-only message
• Update message: If the invoked method changes the value of a variable, then the
invoking message is said to be an update message
130
Components of ODBMS
Object Structure
•Methods
•When a message is passed then the body of code that is executed is
known as a method
• Whenever a method is executed, it returns a value as output. A
method can be of two types:
• Read-only method: When the value of a variable is not affected by
a method, then it is known as the read-only method
• Update-method: When the value of a variable change by a
method, then it is known as an update method
131
Components of ODBMS
Object Structure
•Variables
•It stores the data of an object. The data stored in the
variables makes the object distinguishable from one another
132
Components of ODBMS
Object Classes
•An object which is a real-world entity is an instance of a class.
Hence first we need to define a class and then the objects are
made which differ in the values they store but share the same
class definition
•The objects in turn correspond to various messages and
variables stored in them
133
Components of ODBMS
Object Classes
class CLERK
{ //variables
char name;
string address;
int id;
int salary;
//methods
char get_name();
string get_address();
int annual_salary();
};
In the above example code, we can see, CLERK is a class that holds the object
variables and messages
134
Components of ODBMS
Object Identity
•One goal of an ODBMS is to maintain a direct correspondence between real-world
and database objects so that objects do not lose their integrity and identity and
can easily be identified and operated
•Hence it provides a unique system generated identity to each independent object
stored in the database known as object identifier (OID)
•The value of an OID is not visible to the external user, but is used internally by the
system to identify each object uniquely and to create and manage inter-object
references
•The OID is immutable, OID should be used only once for an object and cannot be
assigned to another object even it is removed from the database
135
Characteristics of ODBMS
• Easy to link with programming language: The programming language
and the database schema use the same type definitions, so there is
no need to learn a new database query language
• No need for user defined keys: ODBMS have an automatically
generated OID associated with each of the objects
• Easy modeling: ODBMS can easily model real-world objects, hence,
are suitable for applications with complex data
• Can store non-textual data: ODBMS can also store audio, video and
image data
136
Advantages of ODBMS
• Speed: Access to data can be faster because an object can be
retrieved directly without a search, by following pointers
• Improved performance: These systems are most suitable for
applications that use object oriented programming
• Extensibility: Unlike traditional RDBMS where the basic-datatypes are
hardcoded, when using ODBMS the user can encode any kind of data
structures to hold the data
137
Advantages of ODBMS
• Data consistency: When ODBMS is integrated with an object-based
application, there is much greater consistency between the database
and the programming language since both use the same model of
representation for the data. This helps avoid the impedance
mismatch
• Capability of handling variety of data: Unlike other database
management systems, ODBMS can also store non textual data like-:
images, videos and audios
138
Disadvantages of ODBMS
• No universal standards: There is no universally agreed standards of operating
ODBMS. This the most significant drawback as the user is free to manipulate data
model as he wants which can be an issue when handling enormous amounts of
data
• No security features: Since use of ODBMS is very limited, there are not adequate
security features to store production-grade data
• Exponential increase in complexity: ODBMS become very complex very fast. When
there is a lot of data and a lot of relations between data, managing and optimizing
ODBMS becomes difficult
• Scalability: Unable to support large systems
• Query optimization is challenging: Optimizing ODBMS queries requires complete
information about the data like-: type and size of data
139