Professional Documents
Culture Documents
MUMBAI – 400049
Roll No.: 14
1
Subject: Database Management System lab
Year: 2021-22
2
INDEX
SR.
PG
NO EXPERIMENT LIST DATE
NO.
.
1 EXPERIMENT:1 07/09/2021 03
2 EXPERIMENT:2 14/09/2021 07
3 EXPERIMENT:3 21/09/2021 10
4 EXPERIMENT:4 28/09/2021 15
5 EXPERIMENT:5 05/10/2021 18
6 EXPERIMENT:6 19/10/2021 20
7 EXPERIMENT:7 26/10/2021 22
8 EXPERIMENT:8 16/11/2021 26
9 EXPERIMENT:9 16/11/2021 30
10 EXPERIMENT:10 23/11/2021 32
11 EXPERIMENT:11
3 30/11/2021 34
12 EXPERIMENT:12 07/12/2021 35
EXPERIMENT 1
AIM:
To study the basics of postgreSQL
DEFINATION:
PostgreSQL is a powerful, open source object-relational database system with over
30 years of active development that has earned it a strong reputation for reliability,
feature robustness, and performance.
HISTORY:
By 1996, it became clear that the name “Postgres95” would not stand the test of
time. The company chose a new name, PostgreSQL, to reflect the relationship between
the original POSTGRES and the more recent versions with SQL capability. At the same
time, they set the version numbering to start at 6.0, putting the numbers back into the
sequence originally begun by the Berkeley POSTGRES project.
LANGUAGE SUPPORT: 4
PostgreSQL support most popular programming languages: Python, Java, C#, C/C+,
Ruby, JavaScript (Node.js), Perl, Go, Tcl
KEY FEATURES:
PostgreSQL has many advanced features that other enterprise-class database
management systems offer, such as:
User-defined types
Table inheritance
Sophisticated locking mechanism
Foreign key referential integrity
Views, rules, sub-query
Nested transactions (save-points)
Multi-version concurrency control (MVCC)
Asynchronous replication
psql -U user -h host Use SSL mode for the -h: used to state the host
“dbname=db connection -U:used to state the
sslmode=require” database user
Command Description Additional Information
history to a file
from a file
CONCLUSION:
Hence we learned about postgreSQL history, key features and basic commands
used in lab.
7
EXPERIMENT 2
AIM:
To study basic postgreSQL commands (create, database, create table, insert,
drop) and execute the queries.
Query 1:
Create database name employee
Syntax:
Query 2:
Using database employee create table emp with the attributes e_name, e_city,
e_number, e_ salary, e_address, dept_name.
Syntax:
8
Syntax:
9
Query 4:
Create another table company with attributes cname,ccity,empno.in database
employee
Syntax:
Query 5:
Insert values into the table company
Syntax:
10
EXPERIMENT 3
AIM :
To study, view and modify the structure of the table (select, update, alter, delete)
and execute the following queries using these commands,
Query 1:
Find the name of all employees who live in Delhi.
Syntax:
Query 2:
Increase the salary of all employee by 5000
Syntax:
Syntax:
12
Query 4:
Change the company city to Gurgaon where the company name is ‘TCS’
Syntax:
Query 5:
Add an attribute name ‘designation’ to the table emp
Syntax:
13
Query 6:
Modify the table emp, change the data type of salary attribute to float
Syntax:
Query 7:
Drop the attribute deptname from the table emp
Syntax:
14
Query 8: Delete the entries from the table company where the number of employees
are less than 20000
Syntax:
15
EXPERIMENT 4
AIM :
To study the commands that involve compound conditions (and, or, in, not in,
between, not between, like, not like) and execute the following queries using this
commands.
Query 1:
Find the names of all employees who live in Gurgaon and whose salary is between RS
50000 and RS 70000.
Syntax:
Query 2:
Find the names of all employees whose name begin with letter S
Syntax:
Syntax:
Syntax:
AIM:
To study the aggregate function (sum, count, max, mean, average) and execute the
following queries using this command.
Query 1:
Find the sum and average of salaries of all employees in finance department.
Syntax:
Query 2:
Find the number of all employees who live in Delhi.
Syntax:
Syntax:
AIM :
To study the grouping commands (group by, order by) and execute the following
queries using this commands.
Query 1:
List all the employee names in descending order.
Syntax:
Query 2:
Find the number of employees in each department where number of employee is
greater than 1.
Syntax:
Syntax:
AIM:
To study the command involving data constraints and execute the following queries
using this commands
Queries 1:
Alter the table ‘emp’ and make ‘enumber’ as the primary key.
Syntax:
Queries 2:
Alter a table company and add the foreign key constraint.
Syntax:
Syntax:
Syntax:
(P.T.O)
Queries 5:
Add a default constraint to column emp_no of a table company with value ‘25000’.
Syntax:
AIM:
To study the commands for aliasing, joins(cross join, inner join, outer join,) and
renaming the various set operations, execute the following queries using this commands.
Queries 1:
Rename the name of database to employee 1.
Syntax:
Queries 2:
Rename the name of table of emp to emp1
Syntax:
Syntax:
Queries 4:
Retrieve the complete record of an employee and it’s company from both the
tables using joins.
Syntax:
Syntax:
Queries 6:
List the e_number of all employees whose residence is in Kalyan and whose
company is in Delhi or if both the conditions are true.
Syntax:
Syntax:
AIM:
To study the commands for views and execute the following queries using this
command.
Queries 1:
Create a view having ename and ecity
Syntax:
Queries 2:
In the above view change the ecity to Delhi where ename is John.
Syntax:
Syntax:
AIM:
To study the commands involving indexes and execute the following queries
Queries 1:
Create an index with attribute e_name on the table employee
Syntax:
Queries 2:
Create a composite index with attributes c_name and c_city on table company.
Syntax:
AIM :
Draw an ER diagram by using dia(software) tools with the relational schemas, Find
out the problem statement, Identify the entities.
EXPERIMENT 12