01 01 Introduction
01 01 Introduction
1. DBMS
2. RDBMS
3. History
4. Types
5. Dbms vs Rdbms
case sensitive.
Case sensitive uppercase or lowercase dogha chalel.
Database Technologies
File
Collection of data on secondary storage device
File=data+Information
4 session: Boot block, Super Block, i-Node list, Data blocks
What is Database
The database is a collection data which is used to retrieve, insert and delete the
data.
A database is an application that stores collection of records.
It allows us to organize data into tables, rows, columns, and indexes to find
information very quickly.
Both (DBMS) and (RDBMS) can follow the ACID properties, but it's essential to
understand the distinction between the two terms.
DBMS:
A DBMS is a software application that provides an interface for interacting with
databases.
It facilitates the creation, maintenance, and retrieval of data from a database.
Not all DBMS systems follow full set of ACID properties,
RDBMS:
An RDBMS is a type of DBMS that is specifically designed to manage relational
databases.
A relational database organizes data into tables (relations) with predefined
schema, and it enforces relationships between tables.
RDBMS full follows ACID.
For example, the account balance before and after the transaction should be correct,
i.e., it should remain conserved.
I means Isolation ensures that concurrent transactions do not interfere with each
other.
For example, when multiple transactions occur at the same time, one transaction
effects should not be visible to the other transactions in the database.
D means Durability: It ensures that once it completes the operation and commits
the data, data changes should remain permanent.
Advantages of DBMS
o Controls database redundancy(storing data in two or more places within a
database):
It stores all the data in one single database file and that recorded data is
placed in the database.
o Data sharing
o Easily Maintenance
o Reduce time
o Backup: It provides backup and recovery subsystems which create automatic
backup of data from hardware and software failures and restores the data if
required.
o multiple user interface: It provides different types of user interfaces like
graphical user interfaces, application program interfaces
Disadvantages of DBMS
o Cost of Hardware and Software
o Size
o Complexity
o Higher impact of failure: Failure is highly impacted the database because in
most of the organization, all the data stored in a single database and if the
database is damaged due to electric failure or database corruption then the
data may be lost forever.
History
1968 File-Based database were introduced data was maintained in a flat file.
Require Prog lang like COBOL, BASIC.
RDBMS
1970 It is the era of RDBMS, proposed by E.F. Codd.
From 1970 to 1972, E.F. Codd published a paper to propose using a relational
database model.
Table->
Row/Record/Tuples
Column/Fields/Attributes
Types of Databases
Relational Database(SQL,MySQL, Oracle)
The data is stored in structured format.
The data is store in table format-> rows(tuple) and columns(attributes)
It also allows to stores relations between table, hence it is called RDBMS
It is secure.
A relational database uses SQL for storing, manipulating, as well as maintaining
the data. E.F. Codd invented the database in 1970.
Each table in the database carries a key that makes the data unique from others.
Examples MySQL, Microsoft SQL Server, Oracle, etc.
1. Key-value storage: It is the simplest type of database storage where it stores every
single item as a key (or attribute name) holding its value, together.
2. Document-oriented Database: A type of database used to store data as JSON-like
document. It helps developers in storing data by using the same document-model format
as used in the application code.
3. Graph Databases: It is used for storing vast amounts of data in a graph-like
structure. Most commonly, social networking websites use the graph database.
4. Wide-column stores: It is similar to the data represented in relational databases. Here,
data is stored in large columns together, instead of storing in rows.
5) Cloud Database
A type of database where data is stored in a virtual environment and executes over
the cloud computing platform.
It provides users with various cloud computing services (SaaS, PaaS, IaaS, etc.) for
accessing the database. There are numerous cloud platforms, but the best options
are:
o Amazon Web Services(AWS)
o Microsoft Azure
o Kamatera
o PhonixNAP
o ScienceSoft
o Google Cloud SQL, etc.
Hierarchical Databases
It is the type of database that stores data in the form of parent-children relationship
nodes. Here, it organizes data in a tree-like structure.
Data get stored in the form of records that are connected via links.
Each child record in the tree will contain only one parent.
On the other hand, each parent record can have multiple child records.
Memory Database-→ MemDB, VoltDB The data is stored in RAM; hence size of
data is very small, but very fast to access
Usually used by researchers
DBMS RDBMS
data is generally stored in either a the tables have primary key and the data
hierarchical form or a navigational are stored in the form of tables.
form.
DBMS does not apply any RDBMS defines the integrity constraint for
security with regards to data the purpose of ACID (Atomocity, Consistency,
manipulation. Isolation and Durability) property.
Slower faster
no security secure
Deadlock in DBMS
A deadlock is a condition where two or more transactions are waiting indefinitely for
one another to give up locks. Deadlock is said to be one of the most feared
complications in DBMS as no task ever gets finished and is in waiting state forever.
For example: In the student table, transaction T1 holds a lock on some rows and needs
to update some rows in the grade table. Simultaneously, transaction T2 holds locks on
some rows in the grade table and needs to update the rows in the Student table held
by Transaction T1.
Now, the main problem arises. Now Transaction T1 is waiting for T2 to release its lock
and similarly, transaction T2 is waiting for T1 to release its lock. All activities come to
a halt state and remain at a standstill. It will remain in a standstill until the DBMS
detects the deadlock and aborts one of the transactions.
Deadlock Avoidance
o When a database is stuck in a deadlock state, then it is better to avoid the database
rather than aborting or restating the database. This is a waste of time and resource.
o Deadlock avoidance mechanism is used to detect any deadlock situation in advance. A
method like "wait for graph" is used for detecting the deadlock situation but this
method is suitable only for the smaller database. For the larger database, deadlock
prevention method can be used.
Deadlock Detection
In a database, when a transaction waits indefinitely to obtain a lock, then the DBMS
should detect whether the transaction is involved in a deadlock or not. The lock
manager maintains a Wait for the graph to detect the deadlock cycle in the database.
The wait for a graph for the above scenario is shown below:
Deadlock Prevention
o Deadlock prevention method is suitable for a large database. If the resources are
allocated in such a way that deadlock never occurs, then the deadlock can be
prevented.
o The Database management system analyzes the operations of the transaction whether
they can create a deadlock situation or not. If they do, then the DBMS never allowed
that transaction to be executed.
Wait-Die scheme
In this scheme, if a transaction requests for a resource which is already held with a
conflicting lock by another transaction then the DBMS simply checks the timestamp of
both transactions. It allows the older transaction to wait until the resource is available
for execution.
Let's assume there are two transactions Ti and Tj and let TS(T) is a timestamp of any
transaction T. If T2 holds a lock by some other transaction and T1 is requesting for
resources held by T2 then the following actions are performed by DBMS:
1. Check if TS(Ti) < TS(Tj) - If Ti is the older transaction and Tj has held some resource,
then Ti is allowed to wait until the data-item is available for execution. That means if
the older transaction is waiting for a resource which is locked by the younger
transaction, then the older transaction is allowed to wait for resource until it is
available.
2. Check if TS(Ti) < TS(Tj) - If Ti is older transaction and has held some resource and if Tj is
waiting for it, then Tj is killed and restarted later with the random delay but with the
same timestamp.
Wound wait scheme
o In wound wait scheme, if the older transaction requests for a resource which is held by
the younger transaction, then older transaction forces younger one to kill the
transaction and release the resource. After the minute delay, the younger transaction is
restarted but with the same timestamp.
o If the older transaction has held a resource which is requested by the Younger
transaction, then the younger transaction is asked to wait until older releases it.
12 Codd's Rules
Every database has tables, and constraints cannot be referred to as a rational
database system. And if any database has only relational data model, it cannot be
a Relational Database System (RDBMS). So, some rules define a database to be
the correct RDBMS. These rules were developed by Dr. Edgar F. Codd (E.F. Codd) in 1985,
who has vast research knowledge on the Relational Model of database Systems. Codd
presents his 13 rules for a database to test the concept of DBMS against his relational
model, and if a database follows the rule, it is called a true relational database (RDBMS).
These 13 rules are popular in RDBMS, known as Codd's 12 rules.
To create a new database using this tool, we first need to launch the MySQL
Workbench and log in using the username and password that you want. It will show
the following screen:
Now do the following steps for database creation:
If we want to create a new database, right-click under the Schema menu and select
Create Schema or click the database icon (red rectangle), as shown in the
following screen.
Enter the new database name (for example, employeedb) and use default
character set and collation.
Now, click on the Apply button as shown in the screen below:
4. A new popup screen appears. Click on the Finish button to complete the database
creation.
5. After successful database creation, we can see new databases in the Schema
menu. If we do not see this, click on the refresh icon into the Schema menu.
6. We can see more information about the database by selecting the database and
click on the 'i' icon. The information window displays several options, like Table,
Triggers, Indexes, Users, and many more.
7. MySQL Workbench does not provide an option to rename the database name, but
we can create, update, and delete the table and data rows from the database.
To drop a database using this tool, we first need to launch the MySQL Workbench and
log in with the username and password to the MySQL server. It will show the
following screen:
Now do the following steps for database deletion:
1. Go to the Navigation tab and click on the Schema menu. Here, we can see all the
previously created databases. If we want to delete a database, right-click the
database that you want to remove, for example, testdb_copy under the Schema
menu and select Drop Schema option, as shown in the following screen.
When we click the Drop Schema option, MySQL Workbench displays a dialog box to
confirm the deletion process. If we select Review SQL, it will produce
the SQL statement that will be executed. And if we choose Drop Now option, the
database will be deleted permanently.
If we want the safe deletion of the database, it is required to choose the Review SQL
option. Once we sure, click the Execute button to execute the statement. The below
screen explains it more clearly:
Once we click the execute button, MySQL will return the below message indicating
that the database is dropped successfully. Since the database testdb_copy is an
empty database, the number of affected rows is zero.
If we verify the schemas tab, we will not find the testdb_copy database on the list
anymore.