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

UNIT 1 - Database System Architecture

Database management system Gtu Sem 3 Ch 1 Branch IT material

Uploaded by

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

UNIT 1 - Database System Architecture

Database management system Gtu Sem 3 Ch 1 Branch IT material

Uploaded by

himansh3156
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

UNIT 1

Database System Architecture

PREPARED BY
PROF. VISHVA UPADHYAY
IT DEPARTMENT
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)

What is Database System


● A Database Management System (DBMS) is a software system that is designed to
manage and organize data in a structured manner. It allows users to create, modify, and
query a database, as well as manage the security and access controls for that database.
● DBMS provides an environment to store and retrieve the data in a convenient and
efficient manner.

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)

1. Physical layer (Internal Layer)


● The physical or internal layer is the lowest level of data abstraction in the
database management system. It is the layer that defines how data is actually
stored in the database.
● It defines methods to access the data in the database. It defines complex data
structures in detail, so it is very complex to understand, which is why it is kept
hidden from the end user.
● Data Administrators (DBA) decide how to arrange data and where to store data.
The Data Administrator (DBA) is the person whose role is to manage the data in
the database at the physical or internal level.

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.

2. Logical Layer (Conceptual Layer)


● The logical or conceptual level is the intermediate or next level of data
abstraction. It explains what data is going to be stored in the database and what
the relationship is between them.
● It describes the structure of the entire data in the form of tables. The logical level
or conceptual level is less complex than the physical level. With the help of the
logical level, Data Administrators (DBA) abstract data from raw data present at
the physical level.

3. View Layer (External Layer)


● View or External Level is the highest level of data abstraction. There are different
views at this level that define the parts of the overall data of the database.
● This level is for the end-user interaction; at this level, end users can access the
data based on their queries.

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

1. Physical Data Independence


● Physical data independence helps you to separate conceptual levels from the
internal/physical levels. It allows you to provide a logical description of the
database without the need to specify physical structures.
● With Physical independence, you can easily change the physical storage structures
or devices with an effect on the conceptual schema. Any change done would be
absorbed by the mapping between the conceptual and internal levels.

Examples of changes under Physical Data Independence


● Using a new storage device like Hard Drive or Magnetic Tapes
● Modifying the file organization technique in the Database
● Switching to different data structures.
● Changing the access method.
● Modifying indexes.
● Changes to compression techniques or hashing algorithms.
● Change of Location of Database from say C drive to D Drive

2. Logical Data Independence

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.

Examples of changes under Logical Data Independence


● Add/Modify/Delete a new attribute, entity or relationship is possible without a rewrite of
existing application programs
● Merging two records into one
● Breaking an existing record into two or more records

5
AHMEDABAD INSTITUTE OF TECHNOLOGY DBMS(3130703)

Difference between Physical and Logical data independence

Structured Query Language (SQL)


● Structured Query Language (SQL),is the database language by which we can perform
certain operations on the existing database, and we can also use this language to create a
database.
● SQL commands are like instructions to a table. It is used to interact with the database
with some operations. It is also used to perform specific tasks, functions, and queries of
data. SQL can perform various tasks like creating a table, adding data to tables, dropping
the table, modifying the table, and setting permission for users.

These SQL commands are mainly categorized into five categories:


1. DDL – Data Definition Language
2. DQL – Data Query Language
3. DML – Data Manipulation Language
4. DCL – Data Control Language
5. TCL – Transaction Control Language

Data Definition Language (DDL)


● DDL or Data Definition Language actually consists of the SQL commands that can be
used to define the database schema

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)
);

Here table_name is name of the table, column is the name of column

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.

CREATE TABLE Student


(Student_id INT (10),
Name VARCHAR(100),
Marks INT (2));
● In the output the table will be created

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)

● ADD using ALTER


Syntax to add column
ALTER TABLE table_name ADD(column_name datatype);
Example
ALTER TABLE Student ADD(Address VARCHAR(200));
● In the output the command will add a new column “Address” in the table Student of data
type varchar(200);

● RENAME using ALTER


Syntax to rename column
ALTER TABLE table_name
RENAME old_column_name TO new_column_name;
The above command will rename the existing column to a new column.

Example
ALTER TABLE Employee RENAME Marks TO Age;
● The command above will change the column_name from Marks to Age

● DROP using ALTER –


Syntax to Drop a column :

ALTER TABLE table_name DROP(column_name);


The above command will delete the existing column.
For example:

ALTER TABLE Employee DROP(Age);


● Here the column_name =”Age”, has been deleted by this command;

● MODIFY using ALTER –


Syntax to Modify a column :

ALTER TABLE Employee MODIFY (column_name datatype);


The above command will modify the existing column .
For example:
ALTER TABLE student MODIFY(name varchar(300));
TRUNCATE COMMAND
This command removes all the records from a table. But this command will not destroy the

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.

Data Manipulation Language (DML)


● A data manipulation language (DML) is a family of computer languages including
commands permitting users to manipulate data in a database. This manipulation involves
inserting data into database tables, retrieving existing data, deleting data from existing
tables and modifying existing data.
● Following are the four main DML commands in SQL:

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:

SELECT * FROM table_name;

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:

Column Names And Values Both

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);

Insert Values to Specific Columns Using INSERT INTO Example

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)

1. UPDATE: Command is used to update the column value in the table.


2. WHERE: Specifies the condition which we want to implement on the table

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

You might also like