UNIT 1 - Database System Architecture
UNIT 1 - Database System Architecture
PREPARED BY
PROF. VISHVA UPADHYAY
IT DEPARTMENT
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
Data Abstraction
● Data abstraction is the procedure of concealing irrelevant or unwanted data from the end
user.
● The database system contains intricate data structures and relations. The developers keep
away the complex data from the user and remove the complications so that the user can
comfortably access data in the database and can only access the data they want, which is
done with the help of data abstraction.
● The main purpose of data abstraction is to hide irrelevant data and provide an abstract
view of the data. With the help of data abstraction, developers hide irrelevant data from
the user and provide them the relevant data. By doing this, users can access the data
without any hassle, and the system will also work efficiently.
● In DBMS, data abstraction is performed in layers which means there are levels of data
abstraction in DBMS
Levels of abstraction
● In DBMS we have three layers for data abstraction
1. Physical Layer (Internal Layer)
2. Logical Layer (Conceptual Layer)
3. View Layer (External Layer)
2
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
● There is a data center that securely stores the raw data in detail on hard drives at
this level.
Advantages
● Users can easily access the data based on their queries.
● It provides security to the data stored in the database.
● Database systems work efficiently because of data abstraction.
3
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
Disadvantages
● It offers complexity at many levels of the database that might create confusion for
developers.
● The navigation becomes extremely difficult when an extra layer is added to the code.
Data Independence
● Data Independence is defined as a property of DBMS that helps you to change the
Database schema at one level of a database system without requiring to change the
schema at the next higher level
● There are two types of data independence
1. Physical data Independence
2. Logical data Independence
Levels of Database
The database has 3 levels
1. Physical/Internal
2. Conceptual
3. External
4
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
● Logical data independence refers to the characteristic of being able to change the
conceptual schema without having to change the external schema.
● Logical data independence is used to separate the external level from the
conceptual view.
● If we do any changes in the conceptual view of the data, then the user view of the
data would not be affected.
● Logical data independence occurs at the user interface level.
5
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
6
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
● It simply deals with descriptions of the database schema and is used to create and modify
the structure of database objects in the database.
● DDL is a set of SQL commands used to create, modify, and delete database structures but
not data. These commands are normally not used by a general user, who should be
accessing the database via an application.
CREATE COMMAND
● CREATE TABLE command creates a new table in the database in SQL.
● SQL CREATE TABLE Statement is used to create a new table in a database.
Users can define the table structure by specifying the column’s name and data
type in the CREATE TABLE command.
● This statement also allows us to create tables with constraints that define the rules
for the table. Users can create tables in SQL and insert data at the time of table
creation.
Syntax
CREATE table table_name
(
Column1 datatype (size),
column2 datatype (size),
.
.
columnN datatype (size)
);
Example :
● in this table the three column_names namely – Student_id is of type int ,Name is of type
varchar and Marks is of type int.
ALTER COMMAND
● An alter command modifies an existing database table. This command can
add up additional columns, drop existing columns and even change the data
type of columns involved in a database table.
7
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
Example
ALTER TABLE Employee RENAME Marks TO Age;
● The command above will change the column_name from Marks to Age
8
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
table’s structure.
Syntax :
TRUNCATE TABLE table_name
● This will delete all the records from the table.For example the below command will
remove all the records from table student.
Example:
TRUNCATE TABLE Student;
DROP COMMAND :
This command completely removes the table from the database along with the destruction of the
table structure.
Syntax –
DROP TABLE table_name
● This will delete all the records as well as the structure of the table.
This is the main difference between TRUNCATE AND DROP.
TRUNCATE only removes the records whereas DROP completely destroys the table.
Example:
DROP TABLE Student;
This command will remove the table records as well as destroy the schema too.
SELECT COMMAND
● This command is used to retrieve rows from a table.
Syntax :
SELECT column_Name_1, column_Name_2, ….., column_Name_N FROM
Table_Name;
● Here, column_Name_1, column_Name_2, ….., column_Name_N are the names of those
columns whose data we want to retrieve from the table.
9
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
● If we want to retrieve the data from all the columns of the table, we have to use the
following SELECT command:
Example 1: This example shows all the values of every column from the table.
SELECT * FROM Student;
Example 2: This example shows all the values of a specific column from the table.
SELECT Emp_Id, Emp_Salary FROM Employee;
● This SELECT statement displays all the values of Emp_Salary and Emp_Id column of
Employee table
Example 3: This example describes how to use the WHERE clause with the SELECT DML
command.
● If you want to access all the records of those students whose marks is 80 from the above
table, then you have to write the following DML command in SQL:
SELECT * FROM Student WHERE Stu_Marks = 80;
INSERT COMMAND
● INSERT is another most important data manipulation command in Structured Query
Language, which allows users to insert data in database tables.
● is used to add/insert new data into the table.
Syntax
● There are two primary syntaxes of INSERT INTO statements depending on the
requirements. The two syntaxes are:
In this method we will specify both the columns which we want to fill and their corresponding
values as shown below:
INSERT INTO table_name (column1, column2, column3)
VALUES ( value1, value2, value);
Parameters:
● table_name: name of the table.
● column1, column2..: name of first column, second column.
10
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
● value1, value2, value..: the values for each specified column of the new record.
Only Values
This method is to specify only the value of data to be inserted without the column names.
INSERT INTO table_name
VALUES (value1, value2, value);
Parameters:
● table_name: name of the table.
● value1, value2: value of first column, second column,… for the new record
Example :
INSERT INTO Student (ROLL_NO, NAME, ADDRESS, PHONE, AGE) VALUES
(1, 'Ram', 'Delhi', 'XXXXXXXXXX', 18);
If we want to insert values in the specified columns then we use the following query.
Query:
INSERT INTO Student (ROLL_NO, NAME, Age)
VALUES ('5','PRATIK','19');
UPDATE COMMAND
● The UPDATE statement in SQL is used to update the data of an existing table in the
database.
● In a very simple way, we can say that UPDATE is used to change the data that is already
in the database.
Syntax :
UPDATE table_name SET column1 = value1, column2 = value2,…
WHERE condition;
Where,
● table_name: name of the table
● column1: name of first, second, third column….
● value1: new value for first, second, third column….
● condition: condition to select the rows for which the
Parameter Explanation
11
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)
Example 1 :
UPDATE Customer SET CustomerName = 'Nitin' WHERE Age = 22;
Example 2:
UPDATE Customer SET CustomerName = 'Satyam', Country = 'USA' WHERE CustomerID =
1;
DELETE COMMAND
● SQL DELETE is a basic SQL operation used to delete data in a database. SQL DELETE
is an important part of database management DELETE can be used to selectively remove
records from a database table based on certain conditions.
Syntax:
DELETE FROM table_name WHERE some_condition;
Parameter Explanation
● Some_condition: condition to choose a particular record.
● table_name: name of the table
Example :
DELETE FROM Employees WHERE NAME = 'Rithvik';
12