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

DBMS notes

The document provides an overview of SQL commands categorized into DDL, DQL, DML, DCL, and TCL, explaining their functions and examples. It also discusses the concepts of physical and logical data independence, emphasizing the ability to modify database structures without affecting higher-level schemas. Additionally, it covers data abstraction and its role in achieving data independence, detailing the three levels of data abstraction: physical, logical, and view.

Uploaded by

Harshdeep Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

DBMS notes

The document provides an overview of SQL commands categorized into DDL, DQL, DML, DCL, and TCL, explaining their functions and examples. It also discusses the concepts of physical and logical data independence, emphasizing the ability to modify database structures without affecting higher-level schemas. Additionally, it covers data abstraction and its role in achieving data independence, detailing the three levels of data abstraction: physical, logical, and view.

Uploaded by

Harshdeep Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

SQL | DDL, DQL, DML, DCL and TCL

Commands
Structured Query Language (SQL) as we all know is the database
language by the use of which we can perform certain operations on
the existing database and also, we can use this language to create a
database. SQL uses certain commands like Create, Drop, Insert, etc.
to carry out the required tasks.
These SQL commands are mainly categorized into four categories
as:

1. DDL – Data Definition Language


2. DQl – Data Query Language
3. DML – Data Manipulation Language
4. DCL – Data Control Language
Though many resources claim there to be another category of SQL
clauses TCL – Transaction Control Language. So we will see in
detail about TCL as well.
1.DDL(Data Definition Language) : DDL or Data Definition
Language actually consists of the SQL commands that can be used
to define the database schema. It simply deals with descriptions of
the database schema and is used to create and modify the structure
of database objects in the database.

Examples of DDL commands:


 CREATE – is used to create the database or its objects (like
table, index, function, views, store procedure and triggers).
 DROP – is used to delete objects from the database.
 ALTER-is used to alter the structure of the database.
 TRUNCATE–is used to remove all records from a table,
including all spaces allocated for the records are removed.
 COMMENT –is used to add comments to the data
dictionary.
 RENAME –is used to rename an object existing in the
database.
2.DQL (Data Query Language) :
DQL statements are used for performing queries on the data within
schema objects. The purpose of the DQL Command is to get some
schema relation based on the query passed to it.
Example of DQL:
 SELECT – is used to retrieve data from the database.
3.DML(Data Manipulation Language): The SQL commands that
deals with the manipulation of data present in the database belong
to DML or Data Manipulation Language and this includes most of the
SQL statements.

Examples of DML:
 INSERT – is used to insert data into a table.
 UPDATE – is used to update existing data within a table.
 DELETE – is used to delete records from a database table.
4.DCL(Data Control Language): DCL includes commands such as
GRANT and REVOKE which mainly deal with the rights, permissions
and other controls of the database system.
Examples of DCL commands:
 GRANT-gives users access privileges to the database.
 REVOKE-withdraw user’s access privileges given by using
the GRANT command.
TCL(transaction Control Language): TCL commands deal with
the transaction within the database.
Examples of TCL commands:
 COMMIT– commits a Transaction.
 ROLLBACK– rollbacks a transaction in case of any error
occurs.
 SAVEPOINT–sets a savepoint within a transaction.
 SET TRANSACTION–specify characteristics for the
transaction.

Physical and Logical Data Independence


1. Physical Data Independence:
Physical Data Independence is defined as the ability to make
changes in the structure of the lowest level of the Database
Management System (DBMS) without affecting the higher-level
schemas. Hence, modification in the Physical level should not result
in any changes in the Logical or View levels.
Note –
There are 3 levels in the schema architecture of DBMS: physical
level, logical level and view level (arranged from the lowest to
highest level).
 Example –
Changes in the lowest level (physical level) are: creating a
new file, storing the new files in the system, creating a new
index etc.
Instances of why we may want to do any sort of Data
modification in the physical level- We may want to alter or
change the data in the physical level. This is because we
may want to add or remove files and indexes to enhance
the performance of the database system and make it faster.
Hence, in this way, the Physical Data Independence enables
us to do Performance Tuning. Ideally, when we change the
physical level, we would not want to alter the logical and
view level.
 How is Physical Data Independence achieved?
Physical Data Independence is achieved by modifying the
physical layer to logical layer mapping (PL-LL mapping). We
must ensure that the modification we have done is
localized.
2. Logical Data Independence:
Logical Data Independence is defined as the ability to make changes
in the structure of the middle level of the Database Management
System (DBMS) without affecting the highest-level schema or
application programs. Hence, modification in the logical level should
not result in any changes in the view levels or application programs.
 Example –
Changes in the lowest level (physical level) are: adding new
attributes to a relation, deleting existing attributes of the
relation etc. Ideally, we would not want to change any
application or programs that do not require to use the
modified attribute.
 How is Logical Data Independence achieved ?
Logical Data Independence is achieved by modifying the
view layer to logical layer mapping (VL-LL mapping).

Data Abstraction and Data Independence


Database systems comprise complex data-structures. In order to
make the system efficient in terms of retrieval of data, and reduce
complexity in terms of usability of users, developers use abstraction
i.e. hide irrelevant details from the users. This approach simplifies
database design.
There are mainly 3 levels of data abstraction:
Physical: This is the lowest level of data abstraction. It tells us how
the data is actually stored in memory. The access methods like
sequential or random access and file organization methods like B+
trees, hashing used for the same. Usability, size of memory, and the
number of times the records are factors that we need to know while
designing the database.
Suppose we need to store the details of an employee. Blocks of
storage and the amount of memory used for these purposes are
kept hidden from the user.
Logical: This level comprises the information that is actually stored
in the database in the form of tables. It also stores the relationship
among the data entities in relatively simple structures. At this level,
the information available to the user at the view level is unknown.
We can store the various attributes of an employee and
relationships, e.g. with the manager can also be stored.
View: This is the highest level of abstraction. Only a part of the
actual database is viewed by the users. This level exists to ease the
accessibility of the database by an individual user. Users view data
in the form of rows and columns. Tables and relations are used to
store data. Multiple views of the same database may exist. Users
can just view the data and interact with the database, storage and
implementation details are hidden from them.
The main purpose of data abstraction is to achieve data
independence in order to save time and cost required when the
database is modified or altered.
We have namely two levels of data independence arising from these
levels of abstraction:
Physical level data independence: It refers to the characteristic
of being able to modify the physical schema without any alterations
to the conceptual or logical schema, done for optimization purposes,
e.g., Conceptual structure of the database would not be affected by
any change in storage size of the database system server. Changing
from sequential to random access files is one such example. These
alterations or modifications to the physical structure may include:

 Utilizing new storage devices.


 Modifying data structures used for storage.
 Altering indexes or using alternative file organization
techniques etc.
Logical level data independence: It refers characteristic of being
able to modify the logical schema without affecting the external
schema or application program. The user view of the data would not
be affected by any changes to the conceptual view of the data.
These changes may include insertion or deletion of attributes,
altering table structures entities or relationships to the logical
schema, etc.

You might also like