DBMS Lab File Rohit

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

SAGE UNIVERSITY

INDORE

Academic Year: 2022-2023


Semester: 3rd

Institute : Institute of Advance Computing


Subject Code: ACTDCDBM001P
Subject Name: DATABASE MANAGEMENT SYSTEM
LAB

Submitted To : Submitted By
Prof.Snehlata Mishra Rohit Malviya
21ADV3CSE0139

INDEX
S.N Name of the Experiment Date of Page no. Remark
Experiment

01 CASE STUDY OF DDL,DML,DQL&DCL


Experiment :-1

CASE STUDY OF DDL,DML,DQL & DCL

SQL is a database computer language designed for the retrieval and management of data in a
relational database. SQL stands for Structured Query Language. This tutorial will give you a
quick start to SQL. It covers most of the topics required for a basic understanding of SQL and to
get afeel of how it works.

1. DDL (data definition language)


Data definition language (DDL) is a language that allows the user to define the data and their
relationship to other types of data.

Data Definition language statements work with the structure of the database table.

 Various data types used in defining columns in a database table


 Viewing, modifying and removing a table structure

DDL Commands

The Data Definition Languages (DDL) Commands are as follows ~

* Create − It is used to create a new table or a new database.’

The basic syntax of this CREATE DATABASE statement is as follows −

CREATE DATABASE Database Name;

* Alter − It is used to alter or change the structure of the database table.

An example of the alter command is as follows

ALTER TABLE student ADD birthdate DATETIME

* Drop − It is used to delete a table, index, or views from the database.

An example of the drop command is as follows −

DROP TABLE student

* Truncate − It is used to delete the records or data from the table, but its structure
remains as it is.

The basic syntax of a TRUNCATE TABLE command is as follows.

TRUNCATE TABLE table name;

2. DML (data manipulation language)


The structured query language (SQL) commands deal with the manipulation of data present in
the database that belongs to the DML or Data Manipulation Language. This includes most of the
SQL statements.

DML Commands

The Data Manipulation Language(DML) Commands are as follows~

* INSERT-Insert command is used to insert data into a table.

The syntax for insert command is as follows –

Insert into <table name> (column list) values (column values);

* UPDATE-Update command is used to update existing data within a table.

The syntax for the update command is as follows –

UPDATE <table name> SET column number =value numberWHERE condition;

* DELETE- Delete command is used to delete records from a database table.

The syntax for the delete command is as follows -

Delete from <table name>WHERE condition;

3. DCL (data control language)


Data control language (DCL) is used to access the stored data. It is mainly used for revoke and to
grant the user the required access to a database. In the database, this language does not have the
feature of rollback.

It helps in controlling access to information stored in a database. It complements the data


manipulation language (DML) and the data definition language (DDL).
DCL Commands

The Data Control Languages (DCL) Commands are as follows ~

* GRANT- It is employed to grant a privilege to a user. GRANT command allows


specified users to perform specified tasks

The syntax for the grant command is as follows –

GRANT privilege_name on objectname to user;

* REVOKE -It is employed to remove a privilege from a user. REVOKE helps the
owner to cancel previously granted permissions.

The syntax for the rervokecommand is as follows –

REVOKE privilege_name on objectname from user;

4. DQL (data query language)


DQL is used to fetch the data from the database.

DQL Commands

The Data Query Languages (DQL) Commands are as follows ~

* SELECT: This is the same as the projection operation of relational algebra. It is used
to select the attribute based on the condition described by WHERE clause.

The syntax for the selectcommand is as follows –

SELECT expressions

FROM TABLES
WHERE conditions;
Experiment No. 2

Apply create, insert and select command on table student with output.

⮚Use of create command


create table student1(
rollno number(10),
sname char(30),
sec char(20),
city char(10)
);
Output:- Table created

⮚Use of insert command


insert into student1 values(101,'Sahil','B','Dewas');
insert into student1 values(102,'Rajat','A','Dewas');
insert into student1 values(103,'Rajshree','B','indore');
insert into student1 values(104,'Kamal','B','Dhar');

Output:- 1 row(s) inserted.


1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.

⮚Use of select command


select * from student1;

Output:-
Experiment No. 3

Apply alter and update command on table student with output.

Input:-
create table student1(
rollno number(10),
sname char(30),
sec char(20),
city char(10)
);

insert into student1 values(101,'Sahil','B','Dewas');


insert into student1 values(102,'Rajat','A','Dewas');
insert into student1 values(103,'Rajshree','B','indore');
insert into student1 values(104,'Kamal','B','Dhar');
select * from student1;

⮚Use of Alter command


alter table student1 add fees number(10);
select * from student1;

⮚Use of update command


update student1 set city='kshipra' where sec='B'
select * from student1;
Experiment No. 4

Apply arithmetic opera(+,-,*,/,%) on table student with output


Input:-

create table student1(


rollno number(10),
sname char(30),
sec char(20),
city char(10),
fees number(10)
);
insert into student1 values(101,'Sahil','B','Dewas',12000);
insert into student1 values(102,'Rajat','A','Dewas',12500);
insert into student1 values(103,'Rajshree','B','indore',13000);
insert into student1 values(104,'Kamal','B','Dhar',11000);
select * from student1;

⮚Addition
select rollno, sname, sec, fees, fees+1000 from student1;
⮚Subtraction
select rollno, sname, sec, fees, fees-1000 as "2023 fees" from
student1;

⮚Multiplication
select rollno, sname, sec, fees, fees*2000 as "extra fees" from
student1;

⮚Division
select rollno, sname, sec, fees, fees/2 as "sch amount" from
student1;

Experiment No. 5
Apply AND,OR,NOT operations on table student with output.
Input:-
create table student1(
rollno number(10),
sname char(30),
sec char(20),
city char(10),
fees number(10)
);

insert into student1 values(101,'Sahil','B','Dewas',12000);


insert into student1 values(102,'Rajat','A','Dewas',12500);
insert into student1 values(103,'Rajshree','B','indore',13000);
insert into student1 values(104,'Kamal','B','Dhar',11000);
select * from student1;

⮚Use of AND operation


select sname from student1 where rollno=101 AND city='Dewas';

Output;-

⮚Use of OR operation.
select sname, fees from student1 where rollno=103 OR
city='Bhopal'
; Output:-
⮚Use of NOT operation.
select sname from student1 where NOT city='dhar';

Output:-
Experiment No. 6

Case study of various Data Models.


#DATA MODEL
Data models define how the logical structure of a database is
modeled . Data Models are fundamental entities to introduce
abstraction in a DBMS . Data models define how data is connected to
each other and how they are processed and stored inside the system .
OR
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 .

Types of data model


Types of database models

There are many kinds of data models. Some of the most common
ones include:
● Hierarchical database model
● Relational model
● Network model
● Object-oriented database model

You might also like