Professional Documents
Culture Documents
DBMS Lab File Raushan
DBMS Lab File Raushan
Session: 2023-24
Program: MCA
PRACTICAL FILE OF
DATABASE AND MANAGEMENT SYSTEM
Submitted By Submitted To
NAME : RAUSHAN KR YADAV Prof. SHAHIL KANSAL SIR
SECTION : 04
ROLL NO : 23SCSE2030416
DATE : JAN,2024 SIGNATURE
0
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
DATABASE : COLLEGE
Design a Database and create required tables. For e.g. Bank, College
Database
Apply the constraints like Primary Key, Foreign key, NOT NULL to the
tables.
CREATE DATABASE :
CREATE TABLES :
1
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
SELECT FUNCTION :
2
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
ALTER :
UPDATE :
3
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
SELECT :
DELETE :
SELECT :
4
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
INNER JOINS :
LEFT JOIN :
RIGHT JOIN :
5
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
MAX() :
MIN() :
AVG() :
COUNT() :
6
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
INTEGRITY CONSTRAINTS :
CRUD Operations must be done with some integrity policy so that DB is always consistent.
Introduced so that we do accidentally corrupt the DB.
DOMAIN CONSTRAINTS
*Restrict the value in the attribute of relation, specifies the Domain.
*Restrict the data types of every attribute.
ENTITY CONSTRAINTS
Every relation should have PRIMARY KEY ,primary not null.
CREATE TABLE STUDENT (
ID INT PRIMARY KEY,
NAME VARCHAR(255) );
REFERENTIAL CONSTRAINTS
*Specified between two relations & helps maintain consistency among tuples of two relations.
*It requires that the value appearing in specified attributes of any tuple in referencing relation also
appear in the specified attributes of at least one tuple in the referenced relation.
*If FK in referencing table refers to PK of referenced table then every value of the FK in referencing table
must be NULL or available in referenced table.
*FK must have the matching PK for its each value in the parent table or it must be NULL
KEY CONSTRAINTS:
The six types of key constraints present in the Database management system are:-
1. NOT NULL: This constraint will restrict the user from not having a NULL value. It ensures that
every element in the database has a value.
CREATE TABLE STUDENT(
ID INT NOT NULL,
NAME VARCHAR(50) );
2. UNIQUE: It helps us to ensure that all the values consisting in a column are different from each
other.
7
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
3. DEFAULT: it is used to set the default value to the column. The default value is added to the
columns if no value is specified for them.
4. CHECK: It is one of the integrity constraints in DBMS. It keeps the check that integrity of data is
maintained before and after the completion of the CRUD.
CREATE TABLE STUDENT(
ID INT,
NAME VARCHAR(255),
AGE INT,
CONSTRAINT age_check CHECK(AGE > 18) );
5. PRIMARY KEY:
This is an attribute or set of attributes that can uniquely identify each entity in the entity set. The
primary key must contain unique as well as not null values.
6. FOREIGN KEY:
Whenever there is some relationship between two entities, there must be some common
attribute between them. This common attribute must be the primary key of an entity set and
will become the foreign key of another entity set. This key will prevent every action which can
result in loss of connection between tables.
CREATE TABLE COURSE (
ID INT ,
NAME VARCHAR(50),
S_ID INT,
FOREIGN KEY(S_ID) REFERENCES STUDENT(ID));
8
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
INSERTION :
UPDATION :
DELETION :
9
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
DATABASE : BANK
Design a Database and create required tables. For e.g. Bank, College
Database
Apply the constraints like Primary Key, Foreign key, NOT NULL to the
tables.
CREATE DATABASE :
CREATE TABLE :
10
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
INSERT VALUE :
SELECT :
11
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
ALTER :
UPDATE :
DELETE :
12
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
MIN() :
MAX() :
COUNT() :
AVG() :
13
NAME: RAUSHAN KUMAR YADAV ROLL NO: 23SCSE2030416
JOINS :
INNER JOIN :
LEFT JOIN :
RIGHT JOIN :
14