0% found this document useful (0 votes)
21 views

DBMS 1

The document discusses different types of databases including relational, distributed, centralized and NoSQL databases. It describes key characteristics like ACID properties and provides examples. The main advantages and disadvantages of different database types are also outlined.

Uploaded by

mohitkandpal461
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

DBMS 1

The document discusses different types of databases including relational, distributed, centralized and NoSQL databases. It describes key characteristics like ACID properties and provides examples. The main advantages and disadvantages of different database types are also outlined.

Uploaded by

mohitkandpal461
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

DBMS

INTRODUCTION OF DBMS
WHAT IS DATABASE ?
The database is a collection of inter-related data which is used to retrieve, insert and delete the data efficiently. It is
also used to organize the data in the form of a table, schema, views, and reports, etc.

For example: The college Database organizes the data about the admin, staff, students and faculty etc.
Using the database, you can easily retrieve, insert, and delete the information.

SCHEMA :- A database schema is a logical representation of data that shows how the data in a database should
be stored logically.

VIEWS:-
•Views in SQL are considered as a virtual table. A view also contains rows and columns.
•To create the view, we can select the fields from one or more tables present in the database.
•A view can either have specific rows based on certain condition or all the rows of a table.
Database Management System
•Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used in different applications.
•DBMS provides an interface to perform various operations like database creation, storing data in it, updating data,
creating a table in the database and a lot more.
•It provides protection and security to the database. In the case of multiple users, it also maintains data
consistency.

DBMS allows users the following tasks:



Data Definition: It is used for creation, modification, and removal of definition that defines the
organization of data in the database.
•Data Updation: It is used for the insertion, modification, and deletion of the actual data in the
database.
•Data Retrieval: It is used to retrieve the data from the database which can be used by applications for
various purposes.
•User Administration: It is used for registering and monitoring users, maintain data integrity, enforcing
data security, dealing with concurrency control, monitoring performance and recovering information
corrupted by unexpected failure.
Characteristics of DBMS
•It uses a digital repository established on a server to store and manage the information.

•It can provide a clear and logical view of the process that manipulates data.

•DBMS contains automatic backup and recovery procedures.

•It contains ACID properties which maintain data in a healthy state in case of failure.

•It can reduce the complex relationship between data.

•It is used to support manipulation and processing of data.

•It is used to provide security of data.

•It can view the database from different viewpoints according to the requirements of the user.
Advantages of DBMS
•Controls database redundancy: It can control data redundancy because it stores all the data in one single
database file and that recorded data is placed in the database.
•Data sharing: In DBMS, the authorized users of an organization can share the data among multiple users.
•Easily Maintenance: It can be easily maintainable due to the centralized nature of the database system.
•Reduce time: It reduces development time and maintenance need.
•Backup: It provides backup and recovery subsystems which create automatic backup of data
from hardware and software failures and restores the data if required.
•multiple user interface: It provides different types of user interfaces like graphical user interfaces, application
program interfaces

Disadvantages of DBMS
•Cost of Hardware and Software: It requires a high speed of data processor and large memory size to run
DBMS software.
•Size: It occupies a large space of disks and large memory to run them efficiently.
•Complexity: Database system creates additional complexity and requirements.
•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.
ACID PROPERTIE
A means Atomicity: This ensures the data operation will complete either with
success or with failure. It follows the 'all or nothing' strategy. For example, a
transaction will either be committed or will abort.
C means Consistency: If we perform any operation over the data, its value before
and after the operation should be preserved. For example, the account balance
before and after the transaction should be correct, i.e., it should remain conserved.
I means Isolation: There can be concurrent users for accessing data at the same
time from the database. Thus, isolation between the data should remain isolated.
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.
Types of Databases
1) Centralized Database
It is the type of database that stores data at a centralized database system. It comforts the users to access the
stored data from different locations through several applications. These applications contain the authentication
process to let users access data securely. An example of a Centralized database can be Central Library that
carries a central database of each library in a college/university.

Advantages of Centralized Database


•It has decreased the risk of data management, i.e., manipulation of data will not affect the core data.
•Data consistency is maintained as it manages data in a central repository.
•It provides better data quality, which enables organizations to establish data standards.
•It is less costly because fewer vendors are required to handle the data sets.

Disadvantages of Centralized Database


•The size of the centralized database is large, which increases the response time for fetching the data.
•It is not easy to update such an extensive database system.
•If any server failure occurs, entire data will be lost, which could be a huge loss.
2)Distributed Database
Unlike a centralized database system, in distributed systems, data is distributed among different database
systems of an organization. These database systems are connected via communication links. Such links help the
end-users to access the data easily. Examples of the Distributed database are Apache Cassandra, HBase,
Ignite, etc.

TYPES OF DISTRIBUTED DATABASE

•Homogeneous DDB: Those database systems which execute on the same operating system and use
the same application process and carry the same hardware devices.
•Heterogeneous DDB: Those database systems which execute on different operating systems under
different application procedures, and carries different hardware devices.

Advantages of Distributed Database


•Modular development is possible in a distributed database, i.e., the system can be expanded by including new
computers and connecting them to the distributed system.
•One server failure will not affect the entire data set.
3)Relational Database
This database is based on the relational data model, which stores data in the form of rows(tuple) and
columns(attributes), and together forms a table(relation). 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 of Relational databases are MySQL,
Microsoft SQL Server, Oracle, etc.

Properties of Relational Database


There are following four commonly known properties of a relational model known as ACID properties, where:
A means Atomicity: This ensures the data operation will complete either with success or with failure. It follows
the 'all or nothing' strategy. For example, a transaction will either be committed or will abort.
C means Consistency: If we perform any operation over the data, its value before and after the operation
should be preserved. For example, the account balance before and after the transaction should be correct, i.e.,
it should remain conserved.
I means Isolation: There can be concurrent users for accessing data at the same time from the database.
Thus, isolation between the data should remain isolated. 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.
4) NoSQL Database
Non-SQL/Not Only SQL is a type of database that is used for storing a wide range of data sets. It is not a
relational database as it stores data not only in tabular form but in several different ways. It came into existence
when the demand for building modern applications increased. Thus, NoSQL presented a wide variety of
database technologies in response to the demands. We can further divide a NoSQL database into the following
four types:
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.

Advantages of NoSQL Database


•It enables good productivity in the application development as it is not required to store data in a structured
format.
•It is a better option for managing and handling large data sets.
•It provides high scalability.
•Users can quickly access data from the database through key-value.
RDBMS
RDBMS stands for Relational Database Management System.

All modern database management systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, and
Microsoft Access are based on RDBMS.

HOW IT WORKS
Data is represented in terms of tuples (rows) in RDBMS.
A relational database is the most commonly used database. It contains several tables, and each table has its
primary key.
Due to a collection of an organized set of tables, data can be accessed easily in RDBMS.
Name Id Phone No.

GEETANSH 1 8976543011

ANKUR 2 8976543011

JATIN 3 4556678992

ASHU 4 9876654335
DIFFERENCE BETWEEN DBMS AND RDBMS
DBMS RDBMS

1) DBMS applications store data as file. RDBMS applications store data in a tabular form.
2) In DBMS, data is generally stored in either a In RDBMS, the tables have an identifier called primary
hierarchical form or a navigational form. key and the data values are stored in the form of tables.

3) Normalization is not present in DBMS. Normalization is present in RDBMS.


4) DBMS does not apply any security with RDBMS defines the integrity constraint for the
regards to data manipulation. purpose of ACID (Atomocity, Consistency, Isolation and
Durability) property.
5) DBMS uses file system to store data, so there in RDBMS, data values are stored in the form of tables,
will be no relation between the tables. so a relationship between these data values will be
stored in the form of a table as well.
6) DBMS has to provide some uniform methods RDBMS system supports a tabular structure of the data
to access the stored information. and a relationship between them to access the stored
information.
7) DBMS does not support distributed RDBMS supports distributed database.
database.
8) DBMS is meant to be for small organization RDBMS is designed to handle large amount of data. it
and deal with small data. it supports single supports multiple users.
user.
9) Examples of DBMS are file systems, xml etc. Example of RDBMS are mysql, postgre, sql
DIFFERENCE BETWEEN FILE SYSTEM AND DBMS
Basis DBMS Approach File System Approach
Meaning DBMS is a collection of data. In DBMS, the user is not required to write the The file system is a collection of data. In this system,
procedures.
the user has to write the procedures for managing the
database.
Sharing of data Due to the centralized approach, data sharing is easy. Data is distributed in many files, and it may be of different formats, so it isn't easy
to share data.
Data Abstraction DBMS gives an abstract view of data that hides the details. The file system provides the detail of the data representation and storage of data.

Security and ProtectionDBMS provides a good protection mechanism. It isn't easy to protect a file under the file system.
Recovery Mechanism DBMS provides a crash recovery mechanism, i.e., DBMS protects the user from The file system doesn't have a crash mechanism, i.e., if the system crashes while
system failure. entering some data, then the content of the file will be lost.

Manipulation DBMS contains a wide variety of sophisticated techniques to store and retrieve The file system can't efficiently store and retrieve the data.
Techniques the data.
Concurrency Problems DBMS takes care of Concurrent access of data using some form of locking. In the File system, concurrent access has many problems like redirecting the file
while deleting some information or updating some information.

Where to use Database approach used in large systems which interrelate many files. File system approach used in large systems which interrelate many files.
Cost The database system is expensive to design. The file system approach is cheaper to design.
Data Redundancy and Due to the centralization of the database, the problems of data redundancy and In this, the files and application programs are created by different programmers
Inconsistency inconsistency are controlled. so that there exists a lot of duplication of data which may lead to inconsistency.

Structure The database structure is complex to design. The file system approach has a simple structure.
Data Independence •In this system, Data Independence exists, and it can be of two types.Logical In the File system approach, there exists no Data Independence.
Data Independence
•Physical Data Independence
Integrity Constraints Integrity Constraints are easy to apply. Integrity Constraints are difficult to implement in file system.
Data Models •In the database approach, 3 types of data models exist:Hierarchal data models In the file system approach, there is no concept of data models exists.
•Network data models
•Relational data models
Flexibility Changes are often a necessity to the content of the data stored in any system, The flexibility of the system is less as compared to the DBMS approach.
and these changes are more easily with a database approach.

Examples Oracle, SQL Server, Sybase etc. Cobol, C++ etc.


DBMS ARCHITECTURE

•The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers, database
servers and other components that are connected with networks.

•The client/server architecture consists of many PCs and a workstation which are
connected via the network.

•DBMS architecture depends upon how users are connected to the database to get
their request done.
Types of DBMS Architecture

1-Tier Architecture

•In this architecture, the database is directly available to the user. It means the user can directly sit on the DBMS
and uses it.
•Any changes done here will directly be done on the database itself. It doesn't provide a handy tool for end users.
•The 1-Tier architecture is used for development of the local application, where programmers can directly
communicate with the database for the quick response.
2-Tier Architecture

•The 2-Tier architecture is same as basic client-server. In the two-tier architecture, applications on the client end
can directly communicate with the database at the server side. For this interaction, API's like: ODBC, JDBC are
used.
•The user interfaces and application programs are run on the client-side.
•The server side is responsible to provide the functionalities like: query processing and transaction management.
•To communicate with the DBMS, client-side application establishes a connection with the server side.
3-Tier Architecture
•The 3-Tier architecture contains another layer between the client and server. In this architecture, client can't directly
communicate with the server.
•The application on the client-end interacts with an application server which further communicates with the database
system.
•End user has no idea about the existence of the database beyond the application server. The database also has no
idea about any other user beyond the application.
•The 3-Tier architecture is used in case of large web application.
Data Models

Data Model is the modeling of the data description, data semantics, and consistency constraints of the data. It
provides the conceptual tools for describing the design of a database at each level of data abstraction. Therefore,
there are following four data models used for understanding the structure of the database:

1) Relational Data Model: This type of model designs the data in the form of rows and columns within a table.
Thus, a relational model uses tables for representing data and in-between relationships. Tables are also called
relations. This model was initially described by Edgar F. Codd, in 1969. The relational data model is the widely used
model which is primarily used by commercial data processing applications.

2) Entity-Relationship Data Model: An ER model is the logical representation of data as objects and relationships
among them. These objects are known as entities, and relationship is an association among these entities. This
model was designed by Peter Chen and published in 1976 papers. It was widely used in database designing. A set
of attributes describe the entities. For example, student_name, student_id describes the 'student' entity. A set of the
same type of entities is known as an 'Entity set', and the set of the same type of relationships is known as
'relationship set'.
3) Object-based Data Model: An extension of the ER model with notions of
functions, encapsulation, and object identity, as well. This model supports a rich type
system that includes structured and collection types. Thus, in 1980s, various
database systems following the object-oriented approach were developed. Here, the
objects are nothing but the data carrying its properties.

4) Semistructured Data Model: This type of data model is different from the other
three data models (explained above). The semistructured data model allows the data
specifications at places where the individual data items of the same type may have
different attributes sets. The Extensible Markup Language, also known as XML, is
widely used for representing the semistructured data. Although XML was initially
designed for including the markup information to the text document, it gains
importance because of its application in the exchange of data.
KEYS
•Keys play an important role in the relational database.
•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.
1.Primary key
•It is the first key used to identify one and only one instance of an entity uniquely. 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.

•In the EMPLOYEE table, ID can be the primary key since it is unique for each employee. In the EMPLOYEE table,
we can even select License_Number and Passport_Number as primary keys since they are also unique.

•For each entity, the primary key selection is based on requirements and developers.
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. The candidate keys are as
strong as the primary key.

For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of the attributes, like SSN,
Passport_Number, License_Number, etc., are considered a candidate key.
Super Key
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.
The super key would be EMPLOYEE-ID (EMPLOYEE_ID, EMPLOYEE-NAME), etc.
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. So we can't store the department's information in the employee table. 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.
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. In other
words, the total number of the alternate keys is the total number of candidate keys minus the primary key. The
alternate key may or may not exist. If there is only one candidate key in a relation, it does not have an 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.
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.

For example, in employee relations, we assume that an employee may be assigned multiple roles, and an
employee may work on multiple projects simultaneously. So the primary key will be composed of all three
attributes, namely Emp_ID, Emp_role, and Proj_ID in combination. So these attributes act as a composite key
since the primary key comprises more than one attribute.

key is also known as Concatenated Key.


Artificial key
The key created using arbitrarily assigned data are known as artificial keys. 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 a serial order.
For example, the primary key, which is composed of Emp_ID, Emp_role, and Proj_ID, is large in employee
relations. So it would be better to add a new virtual attribute to identify each tuple in the relation uniquely.
XAMPP INSTALLATION STEPS
COMMAND PROMPT
CREATING DATABASE
SHOW DATABASE
WORK ON SPECIFIC DATABASE
CREATE TABLE
STRUCTURE OF TABLE
INSERT DATA
INFORMATION RETRIVE FROM TABLE
SQL DAY -2
SHOW DATABASES
WORK ON SPECIFIC DATABASE
1. RETRIVE ALL DATA USING SELECT COMMAND
2. RETRIVE DATA SPECIFIC COLUMN USING SELECT COMMAND
3.RETRIVE DATA SPECIFIC COLUMN USING SELECT COMMAND
OPERATOR

&& AND OPERATOR

|| OR OPERATOR

NOT NOT OPERATOR


1. OR OPERATOR (ANY CONDITION IS TRUE)
2. AND OPERATOR(BOTH CONDITION SHOULD BE
TRUE)
3. NOT OPERATOR(NEGATIVE THE OUTPUT ANY BOOLEAN EXPRESSION)
BETWEEN CLAUSE
IN CLAUSE(IT IS USED TO SHOW LIST)
SQL DAY - 3
AGGREGATE FUNCTION
SUM
MAXIMUM
MINIMUM
AVERAGE
COUNT
CONDITION BASED ON PATTERN
START WITH
END WITH
CENTER WITH
NO. OF
ALPHABET
ORDER BY CLAUSE

• ASCENDING
• DESCENDING
DESCENDING ORDER
ASCENDING ORDER
TWO QUERIES IN ONE
DIFFERENCE BETWEEN DROP DELETE AND TRUNCATE

The DELETE command deletes one or more existing


records from the table in the database.

The DROP Command drops the complete table from


the database.

The TRUNCATE Command deletes all the rows from


the existing table, leaving the row with the column
names.

You might also like