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

DBMS

The document discusses key concepts related to database management systems (DBMS). It defines what a database and DBMS are, and explains that a DBMS is software used to create and manage databases. The document also covers the evolution of database types from file-based to relational to non-relational databases. It discusses important DBMS features like data modeling, storage and retrieval, concurrency control, and integrity and security. The document also compares DBMS approaches to file system approaches.

Uploaded by

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

DBMS

The document discusses key concepts related to database management systems (DBMS). It defines what a database and DBMS are, and explains that a DBMS is software used to create and manage databases. The document also covers the evolution of database types from file-based to relational to non-relational databases. It discusses important DBMS features like data modeling, storage and retrieval, concurrency control, and integrity and security. The document also compares DBMS approaches to file system approaches.

Uploaded by

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

DBMS

What is Data ?
Ans : Data is a raw fact that is not processes into information.
What is Information ?
Ans : Information that is consist of raw bytes in processed form/
Information is nothing but that data being viewed in a structured
format.
What is a Database?
Ans : A location where data is stored form where it can be easily
accessed modify and update . A database is an organized collection of
related data, so that it can be easily accessed and managed. The main
purpose of the database is to operate a large amount of information by
storing, retrieving, and managing data.

Evolution of Database :

1. File-Based : Data was maintained in file


2. Hierarchical : Files consisting of data in a parent child tree
manner.
3. Network : files are related as owners and members
4. 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).
5. Cloud : Cloud database facilitates you to store, manage, and
retrieve their structured, unstructured data via a cloud
platform.
6. NOSql : A NoSQL database is an approach to design such
databases that can accommodate a wide variety of data
models.

What is DBMS ?
Ans : Database Management System is software or technology used to
manage data from a database. DBMS is a system that enables you to
store, modify and retrieve data in an organized way. It also provides
security to the database.
Features Of DBMS ?
Ans :
Data modeling: A DBMS provides tools for creating and modifying
data models, which define the structure and relationships of the data
in a database.
Data storage and retrieval: A DBMS is responsible for storing and
retrieving data from the database, and can provide various methods
for searching and querying the data.

Concurrency control: A DBMS provides mechanisms for controlling


concurrent access to the database, to ensure that multiple users can
access the data without conflicting with each other.

Data integrity and security: A DBMS provides tools for enforcing


data integrity and security constraints, such as constraints on the
values of data and access controls that restrict who can access the
data.

Backup and recovery: A DBMS provides mechanisms for backing up


and recovering the data in the event of a system failure.

DBMS can be classified into two types: Relational Database


Management System (RDBMS) and Non-Relational Database
Management System (NoSQL or Non-SQL)

RDBMS: Data is organized in the form of tables and each table has a
set of rows and columns.

NoSQL: Data is organized in the form of key-value pairs, document,


graph, or column-based. These are designed to handle large-scale,
high-performance scenarios.

Difference Between DBMS and File system ?

Ans : Redundancy of data: Data is said to be redundant if the same


data is copied at many places. Inconsistency of Data: Data is said to
be inconsistent if multiple copies of the same data do not match each
other.

Basis DBMS Approach File System Approach


Meaning DBMS is a collection The file system is a collection
of data. In DBMS, the of data. In this system, the
user is not required touser has to write the
write the procedures. procedures for managing the
database.
Sharing of data Due to the centralized Data is distributed in many
approach, data sharing files, and it may be of
is easy. different formats, so it isn't
easy to share data.
Data DBMS gives an The file system provides the
Abstraction abstract view of data detail of the data
that hides the details. representation and storage of
data.
Security and DBMS provides a It isn't easy to protect a file
Protection good protection under the file system.
mechanism.
Recovery DBMS provides a The file system doesn't have
Mechanism crash recovery a crash mechanism, i.e., if the
mechanism, i.e., system crashes while entering
DBMS protects the some data, then the content of
user from system the file will be lost.
failure.
Concurrency DBMS takes care of In the File system, concurrent
Problems Concurrent access of access has many problems
data using some form like redirecting the file while
of locking. deleting some information or
updating some information.
Cost The database system is The file system approach is
expensive to design. cheaper to design.
Data Due to the In this, the files and
Redundancy and centralization of the application programs are
Inconsistency database, the problems created by different
of data redundancy and programmers so that there
inconsistency are exists a lot of duplication of
controlled. data which may lead to
inconsistency.
Structure The database structure The file system approach has
is complex to design. a simple structure.

Define ?
Tuple - A tuple is a single row in a database that contains a single
record.
Cardinality : cardinality represents the number of times an entity of
an entity set participates in a relationship set. Or we can say that the
cardinality of a relationship is the number of tuples (rows) in a
relationship.

Degree : The total number of attributes that comprise a relation is


known as the degree of the table.

Cardinality : The total number of tuples at any one time in a relation


is known as the table's cardinality. The relation whose cardinality is 0
is called an empty table.

What is Data Integrity Constraints in RDBMS ?


Ans – Integrity constraints are sets of rules that maintains the quality
of data .
Entity integrity: It specifies that there should no be any null value in
primary key attribute.

Domain integrity: It enforces certain rules and constraints on values


that column can hold like the type, the format, or the range of values.

Referential integrity: In the Referential integrity constraints, if a foreign key in


Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key in
Table 1 must be null or be available in Table 2
Key constraints : keys are entity set which can define their entity
within the set uniquely.

What is Database Archietecture Types?


Ans – Any DBMS architecture mainly consists of three levels of
Conceptual level

o It describes the logical structure of the database , Specifies


what type of data can be stored in the database by defining
the data type .It also specifies the relationship between
tables

Example : Create table emp(id num(5) primary key ,name


varchar(10));

External level

o External level describe users view of the database

Internal level

o This is the lowest level of abstraction describes how


physical data is stored .It provides details about
the complex data structures that are used for storage of
data

1 Tier - In this architecture, the database is directly available to the


user. It means the user can directly sit on the DBMS and uses it.Eg -
to learn SQL we set up an SQL server and the database on the
local system.

2 Tier - 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. To communicate
with the DBMS, client-side application establishes a connection with
the server side.Eg – Banking system
3 Tier –
Database Tier (Internal Level) – The raw data is present at this tier
along with its DBMS system language and its queries that allow
different operation on the DB.
Application Tier – This acts as an intermediary between the database
tier and the user.
Presentation Tier – This also known as user tier. Here the user is able
to view all the database results.
DBMS architecture provides two types of data independence

1. Logical data independence


2. Physical data independence

Logical data independence


Logical data Independence states that external level is completely
unaffected are free from any changes that are made at the conceptual
level and vice-versa / Logical data independence is a method that makes sure
that if we make modifications to the table format, the data should not be affected.
Eg :
 To divide an existing record into two or more records.
 Merging two records into a single one.

Physical data independence

Physical data Independence states that conceptual level is completely


unaffected are free from any changes that are made at the internal
level and vice-versa / Physical data independence allows you to modify
physical storage structures or devices without affecting the conceptual model of the
database.

Examples of Physical Data Independence:

 Changing from one data structure to another.


 Making use of new storage technology
TYPES OF DBMS MODELS ?
Ans –

Flat file DBMS

 The file management system was the first method used to store
data in the computer is a database
 Each data item is stored on a disc sequentially in one large file
 If you want to locate a particular item the search start from the
beginning and each item is checked one by one sequentially till
the match is found.
Drawbacks
Data duplication, very poor security, retrieving of data is very
slow,

Hierarchical DBMS -organize data like a tree structure .The


hierarchical data model is implemented based on one too many
relations between parent and child records. Eg – IBM information
management system Advantage : Searching is easy coz there is only
one parent for many child
Network Model - In this data, the model will maintain less duplicate data because
their parent-child records are implemented based on many-many relation .

What is ACID Property ?

Ans :

Atomcity - The term atomicity defines that the data remains atomic. It
means if any operation is performed on the data, either it should be
performed or executed completely or should not be executed at all. It
further means that the operation should not break in between or
execute partially.

Consistency - The word consistency means that the value should


remain preserved always. In DBMS, the integrity of the data should
be maintained, which means if a change in the database is made, it
should remain preserved always

Isolation - This property ensures that multiple transactions can occur


concurrently without leading to the inconsistency of the database
state. Transactions occur independently without interference.
Changes occurring in a particular transaction will not be visible to
any other transaction until that particular change in that transaction is
written to memory or has been committed.

Durability - In DBMS, the term durability ensures that the data after
the successful execution of the operation becomes permanent in the
database. The durability of the data should be so perfect that even if
the system fails or leads to a crash, the database still survives with the
help of a secondary disk.

What is ER Model ?

Ans - This model is used to define the data elements and relationship for a
specified system.It develops a conceptual design for the database.

Weak Entity – Entity that doesn’t contain any key attribute and depends on
other entity . Represented by double box

Attributes – Represented by Eclipse

Key Attribute – Represnts a primary key and is denoted by ellipse with


underline.

Composite Attribute :An attribute that composed of many other attributes is known
as a composite attribute. The composite attribute is represented by an ellipse, and
those ellipses are connected with an ellipse.

Multivalued Attribute :An attribute can have more than one value. These attributes
are known as a multivalued attribute. The double oval is used to represent
multivalued attribute.For example, a student can have more than one phone
number.
Derived Attribute : An attribute that can be derived from other attribute is known as
a derived attribute. It can be represented by a dashed ellipse.

Link : https://www.javatpoint.com/dbms-er-model-concept

Keys : https://prepinsta.com/dbms/keys/

Specialization and Generalization : https://www.scaler.com/topics/specialization-and-


generalization-in-dbms/

Generalization Specialization
Generalization is a bottom-up manner approach Specialization is a top-down manner approach
In Generalization, schema size reduces. In Specialization, schema size increases.
Generalization is applied to a group of entities. Specialization is applied to a single entity.
Generalization forms a single entity from Specialization forms multiple entities from a
multiple entities. single entity.
Inheritance is not used in generalization. Inheritance can be used in specialization.

What is Normalization ?

Ans :Normalization is a database design technique that reduces data


redundancy and eliminates undesirable characteristics like Insertion,
Update and Deletion Anomalies. Normalization rules divides larger
tables into smaller tables and links them using relationships. The
purpose of Normalisation in SQL is to eliminate redundant (repetitive)
data and ensure data is stored logically.

o Insertion Anomaly: Insertion Anomaly refers to when one cannot insert a


new tuple into a relationship due to lack of other data or attributes.
o Deletion Anomaly: The delete anomaly refers to the situation where the
deletion of unwanted data results in the unintended loss of some other
important data.
o Updatation Anomaly: The update anomaly is when an update of a single
data value requires multiple rows of data to be updated.

1st Normal Form : Every column should have same name and should maintain domain
integrity and most important there should not be any multivalue attribues in a
column.

2nd Normal Form : The table should be in 1 st NF and there should not be any partial
dependency of a non-prime attribute on a prime attribute . For Eg : There are four
attributes A,B,C,D in which A&B determines D and B Determines C and A&B are
prime attributes and C&D are non prime attributes . So if there is a partial
dependency between B and C then if the value of B attribute is NULL then it would
not be possible to determine D , but in the case of C since it is fully dependent on
both A&B then even if the value of B is Null it can be determine by A alone.

3rd Normal Form : The table should be in 2 nd Normal Form and there should not be
any transitive dependency(when a non-prime attribute determines another non-
prime attribute) between non prime attributes . For Eg - There are four attributes
A,B,C,D in which A&B determines C and C Determines D and A&B are prime
attributes and C&D are non prime attributes . In this scenario A&B tries to determine
D with the help of C which is an non-prime attributes , but since C is an NPA there is
a possibility that C may be NULL in that case it would be difficult to find the D. In
order to solve this we will make two tables one in which A&B will determine C and
one in which C will act as PA and determines D .
Boyce Codd Normal Form : It states that the attribute should belongs to a super key
in-order to derive another attribute which could possibly be a prime attribute also.

DENORMILIZATION : It is a process of optimizing the efficiency of database by


adding redundant data into the tables by avoiding the costly JOIN operations in
order to retrive data from multiple tables.It does not mean that normalization is not
done . It is the process after normalizing .
https://www.scaler.com/topics/denormalization-in-dbms/

CONSTRAINTS :

Default : when a default clause or constraint is applied on a column , the rows gets
inserted with that default value if the user has not given a value.

Not Null : Column should have values other than Null Value. Null value is different
from zero value or a field that contain spaces Null represents a record where data may be
missing data or data for that record may be optiona

Unique : It ensures that all the data in the columns are unique . It can be applied to
any number of columns.

Primary Key Unique Key

Identifies a record uniquely in a table It helps to maintain unique data in the required columns of the
table

It will not allow null values It helps to maintain unique data in the required columns of the
table

Only one primary key is allowed in a A unique key can be applied to any number of columns in the table
table

Check : It helps to verify whether the data enter by user satisfy the condition or not.
Relational Algebra :
https://www.geeksforgeeks.org/introduction-of-relational-
algebra-in-dbms/

Indexing : Normally when we write a query , the data is fetched from


the secondary memory and hen brought in main memory but of the
data is unordered than we have to swap in & swap out more no of
blocks by searching for the required data in main memory . This is very
much time-consuming hence indexing will solve this issue to retrive the
data mor quickly. Index Table consist of a pointer and a key .

Types of Indexing :

1.Primary Index: When the data file is ordered and unique it satisfy the primary
index condtion .
1. Primary Index : The index table which is formed using primary key is called as
primary index . It is operated on unique key and ordered data (sorted).
It is of two type :
Dense Indexing : In this technique for every record in a block of database ,
individual key and pointer is been inserted in index table. Due to this searching
becomes fast but it takes more memory .
II. Sparse Indexing : In this technique , search is slow and pointer for a block is stored
which contains a limited set of data and not for individual data as in dense ,
consumes less memory.

2. Clustered Indexing : In this technique the data is ordered and not unique , hence
to access the data we use a concept called as block hanger inorder to access the data
that might be present in multiple blocks. https://www.youtube.com/watch?
v=UpJ9ICmzaAM

3. Secondary Index : Consider a table which consist of Eid,name and pan card , so we
can use primary index if we want to search a data based on Eid since it is unique and
sorted , but atimes we require to search a data based on unordered data hence
primary index will not work in that case . Hence secondary index is used , suppose we
want to search a data based on pan card so we will create a dense secondary index
or if we want to search data based on name then we can use this index.

Functional Dependency : It is used to identify the relation between the attributes.


1.Trivial dependency- If the dependent attribute is a subset of determinant attribute .

2. Non-Trivial dependency- The dependent attribute is not a subset of determinant


attribute.

3.Multivalued dependency- The depending attributes are not depending on each


other.

4. Transitive dependency – the depending attribute is dependent on determinant


attribute indirectly.

SQL
SQL is a standard database language used to access and manipulate data in databases. SQL
stands for Structured Query Language. SQL was developed by IBM Computer Scientists in the
1970s.

SQL Datatypes:

1.Numeric : smallint(2 bytes),int(4 bytes),bigint(6 bytes).

2. Character : char(fixed length), varchar(variables length). The main difference between char
and varchar is that in char if the input is less than the fixed length than it is padded with extra
memory space whereas in varchar it is ok if the length is less than the mentinoned argument.

3. Date : It has DATE function which has format YYYY-MM-DD. Select NOW is used for
getting the latest date and time.

4.Binary Large Object (BLOB): It is used to store binary objects like images and
audios.

Types of Language :

1.DDL : It is called as data definition language which is used to define the structure of database
and also the storage for it.

Create : It is used to create tables/database.


Eg : CREATE TABLE EMPLOYEE (
emp_id int PRIMARY KEY,
emp_name varchar(50),
emp_dob Date(),
emp_address varchar(50) );

Alter : It is used to alter the structure of database. Specifically it is used for


modifying the columns of the database.
 To add the columns: ALTER TABLE table_name ADD (column1
datatype,..);
 To delete a column : ALTER TABLE table_name DROP column_name;
 To modify the column : ALTER TABLE table_name MODIFY (column1
datatype,…..);
DROP: It is used to delete a whole database or just a table. The major difference
between TRUNCATE and DROP is that truncate is used to delete the data inside the
table not the whole table.
Eg : DROP TABLE/DATABASE table_name/database_name;
Truncate : It is used to delete the table details but the structure is preserved.
DROP vs TRUNCATE
 Truncate is normally ultra-fast and it’s ideal for deleting data from a
temporary table.
 Truncate preserves the structure of the table for future use, unlike drop
table where the table is deleted with its full structure.

COMMENT : It is used to give comments in sql language . Single line comment


(-),multi-line comment (/*……*/).

RENAME : Used to rename the table or column. ALTER TABLE table_name


RENAME TO new_name; or ALTER TABLE table_name RENAME column_name
TO new_name;

2. DQL: It is used as data query language which is used to perform queries on


the database objects. SELECT- It is used to retrieve data from the database.

3. DML : It deals with the modification of the data in the database.

INSERT INTO :
 Inserting with column and value : INSERT INTO table_name
(columns….) VALUES (values….);
 Inserting with only value : INSERT INTO table_name
VALUES(values….);
 Inserting the values from other table : INSERT INTO table1 SELECT
* FROM table2;
 Inserting specific columns from other table : INSERT INTO table1
(column1,column2) SELECT column1,column2 FROM table2;

UPDATE : It is used to update the data in the table.


 To update a column: UPDATE table_name SET column1=value1,
….WHERE condition;
DELETE : It is used to delete single or multiple records from the database.
 DELETE FROM table_name WHERE some_condition;
 DELETE * FROM table_name WHERE condition;
 It can be rolled back or undone.
Delete Truncate

The DELETE command is used to delete While this command is used to


specified rows(one or more). delete all the rows from a table.

It is a DML(Data Manipulation Language) While it is a DDL(Data Definition


command. Language) command.

There may be a WHERE clause in the


While there may not be WHERE
DELETE command in order to filter the
clause in the TRUNCATE command.
records.

DCL : It is used to deal with rights,permission of the database.

GRANT – It is used to grant permission to users

Revoke – It is used to take away the privilegdes and rights from the user.

TCL : Transaction refers to a set of tasks which is executed as a single execution unit.

BEGIN : It is used to begin the transaction. BEGIN TRANSACTION transaction_name ;

SET TRANSACTION: Places a name on a transaction.

Commit – It is used to commit the changes on the database COMMIT;

Rollback – It is used to rollback the changes from a certain point. ROLLBACK;

Savepoint – It is a point from where the rollback can be performed rather than
rollbacking entire transaction.

DD
L TCL

It stands for Data Definition It stands for Transaction Control


1.
Language. Language.

It is used to define data It contains those commands, which are


2. structures or overall database used to manage transactions within the
schema. database.
DD
L TCL

By using DDL commands,


TCL commands are meant to handle
3. database transactions cannot be
database transactions.
handled.

Files can be easily maintained It manages the different tasks with the
4.
by DDL commands. important feature, Atomicity.

Where clause : It is used to filter the records without grouping based on a condition.

Group by clause : It is used to group the rows based on a specific column.It is used
with aggregrate functions like avg,count,min,max.

Joins : A JOIN clause is used to combine rows from two or more tables, based
on a related column between them.

Natural Join : Natural Join in SQL combines records from two or more tables
based on the common column between them. The common column must have
the same name and data type in both the tables. SQL joins the tables based on
this common column and hence, we do not need to explicitly specify the join
condition.

SELECT * FROM tableA NATURAL JOIN tableB

The INNER JOIN keyword selects records that have matching values in
both tables.

The LEFT JOIN keyword returns all records from the left table
(table1), and the matching records from the right table (table2).

The RIGHT JOIN keyword returns all records from the right table
(table2), and the matching records from the left table (table1).

The FULL OUTER JOIN keyword returns all records when there is a
match in left (table1) or right (table2) table records.

DBMS RDBMS

DBMS stores data as file. RDBMS stores data in tabular form.


DBMS RDBMS

Data elements need to access Multiple data elements can be accessed at


individually. the same time.

Data is stored in the form of tables which


No relationship between data.
are related to each other.

Normalization is not present. Normalization is present.

It deals with small quantity of data. It deals with large amount of data.

Data redundancy is common in this Keys and indexes do not allow Data
model. redundancy.

It is used for small organization and


It is used to handle large amount of data.
deal with small data.

What are Triggers ?

Ans : It is a short piece of code that gets exceuted automatically when a set of
events occurred on a table .It plays an important role in maintain the data
integrity and consistency. Eg : John is a marketing officer in a company so
when a new customer comes they had to send a greeting msg , if it were 2-3
customers john could have done it manually but what if there are more
customers.

Syntax :

Create Trigger trigger_name

(Before | After) [insert,update,delete]

On table_name
For each row | for each column

What are clustered and non-clustered Indexes?


Clustered indexes are the index according to which data is physically stored on
a disk. Therefore, only one clustered index can be created on a given database
table.
Non-clustered indexes don’t define the physical ordering of data, but logical
ordering.

Stored procedures are prepared SQL code that you save so you can reuse it over and
over again. So if you have an SQL query that you write over and over again, save it
as a stored procedure and call it to run it. You can also pass parameters to stored
procedures so that the stored procedure can act on the passed parameter values.
Stored Procedures are created to perform one or more DML operations on Database.
It is nothing but the group of SQL statements that accepts some input in the form of
parameters and performs some task and may or may not return a value.

UNION and UNION ALL are used to join the data from two or more
tables. However,

 UNION removes duplicate rows and picks. The rows are distinct
after combining the data from the tables were
 UNION ALL does not remove the duplicate rows; it just picks all
the data from the tables.

The transparent DBMS keeps its physical structure hidden from


users.
Data independence is the ability to modify the scheme without affecting the programs and the
application to be rewritten.

Views in SQL are kind of virtual tables. A view also has rows and columns as
they are in a real table in the database.

B-TREE : It is a balanced tree which has a leaf node at same level . It is used for
the indexing purposes to create a index table by using tree data structure in which a
node represent key value and pointer to point in the secondary memory.

 NOSQL : It means NO SQL i.e it works with unstructured non relational data like document
based or key-value pair . Eg – MONGO DB . It supports semi-structured data and volatile
data
No, a NULL value is distinct from zero and blank space in that it denotes a
value that is assigned, unknown, unavailable, or not applicable, as opposed to
blank space, which denotes a character, and zero, which denotes a number.
For instance, a NULL value in "number of courses" taken by a student
indicates that the value is unknown, but a value of 0 indicates that the
student has not taken any courses.

You might also like