087 Khushboo
087 Khushboo
087 Khushboo
Submitted By
Name- KHUSHBOO
Enrollment Number- 08701012022
Batch- CSE-2 (A2)
Year- Second
Semester- 3
Submitted To
Professor Devender Kumar Tayal
Department of Computer Science and Engineering
INDEX
IMPORTANCE OF DBMS
LAB - 2
INTRODUCTION TO ER-DIAGRAMS
Ex-college database
Ex-library database
LAB - 3
INTRODUCTION TO DDL, DML AND DCL
DDL-Data Definition Language
DDL Commands- ALTER DATABASE , ALTER EVENT , ALTER
FUNCTION , ALTER INSTANCE , ALTER PROCEDURE , ALTER
SERVER , ALTER TABLE , ALTER TABLESPACE , ALTER VIEW ,
CREATE DATABASE , CREATE EVENT , CREATE FUNCTION ,
CREATE INDEX , CREATE PROCEDURE and CREATE
FUNCTION , CREATE SERVER , CREATE TABLE , CREATE
TABLESPACE , CREATE TRIGGER, CREATE VIEW , DROP
DATABASE , DROP EVENT , DROP FUNCTION , DROP INDEX ,
DROP LOGFILE GROUP , DROP PROCEDURE and DROP
FUNCTION s, DROP SERVER , DROP TABLE , DROP
TABLESPACE , DROP TRIGGER , DROP VIEW , RENAME TABLE
, TRUNCATE TABLE ,COMMENT.
LAB – 4
INTRODUCTION TO SQL
SQL stands for Structured Query Language. SQL is a standard
language for accessing and manipulating databases. SQL can
execute queries against a database. SQL can retrieve data, insert
records, update records, delete records, create new databases,
create new tables, create stored procedures, can create views in a
database, set permissions on tables, procedures, and views, etc.
MySQL
MySQL is a relational database management system based on the
Structured Query Language. MySQL is open-source and free
software under the GNU licence. It is supported by Oracle
Company. MySQL is currently the most popular database
management system software used for managing the relational
database. It is fast, scalable, and an easy to use database
management system in comparison with Microsoft SQL Server and
Oracle Database. It is commonly used in conjunction with PHP
scripts for creating powerful and dynamic server-side or web-based
enterprise applications. It is developed, marketed, and supported by
MySQL AB, a Swedish company, and written in C programming
language and C++ programming language. MySQL supports many
Operating Systems like Windows, Linux, MacOS, etc. with C, C++,
and Java languages.
LAB – 5
DATABASE QUERIES
Q1) Write a query to create a database with the name IGDTUW.
ans)CREATE DATABASE IGDTUW;
LAB – 6
SQL DATA TYPES
1 int-int(size) data type stores a medium integer. Signed range is
from -2147483648 to 2147483647.
LAB – 7
ATTRIBUTE CONSTRAINTS
1. NOT NULL-The NOT NULL constraint enforces a column to not
accept NULL values. This enforces a field to always contain a
value, and we cannot insert a new record, or update a record
without adding a value to this field.
Q1) Write a query to add a not null column into the table.
ans)USE THE ALTER TABLE;
Q3) Write a query to add a primary key column into the table.
ans)ALTER TABLE [TABLE NAME] ADD PRIMARY KEY(ID);
Q4) Write a query to add a foreign key column into the table.
ans)ALTER TABLE TABLE_NAME ADD CONSTRAINT_NAME
FOREIGN KEY(FOREIGN KEY NAME) REFERENCES PARENT
TABLE(COLUMN NAME);
LAB – 8
CREATE TABLES
Q) Create tables.
1)student table
2)company table.
create database company_xyz;
use company_xyz;
create table employee_info(
id int primary key,
name varchar(50),
salary int not null
);
insert into employee_info
(id,name,salary)
values
(1,"adam",25000),
(2,"bob",30000),
(3,"casey",40000);
select* from employee_info;
LAB – 9
SQL QUERIES TO EDIT A TABLE
Q3) write sql queries to explain the difference between drop and
truncate command.
show tables;
select*from teacher_info;
show tables;
LAB – 10
SQL QUERIES TO INSERT AND UPDATE DATA IN TABLE
Q1) Write a query to retrieve all values from the table student.
Q3) Write a query to select the first 3 records from the student_info
table.
Q3) Write a query to find the minimum marks of all the students.
Q4) Write a query to find the maximum marks of all the students.
Q1) Write a query to select all the teachers where joining date is
12-11-2004.
Q2) Write a query to select all the teachers who are joining in the
year 2022.
Q3) Write a query to select all the faculty who joined the university
at least 5 years ago.
Q2) Write a query to list the number of students in each city sorted
from high to low.
Q3) Write a query to select the student name who has marks
greater than 85
LAB 16
SQL QUERIES FOR ALIASES
Q1) Write a sql query to create aliases for first name and emp_ID.
Q2) Write a sql query to create an alias “name” from Finance table
LAB - 17
JOIN OPERATIONS
● SQL LEFT OUTER JOIN includes in a result table unmatched rows from
the table that is specified before the LEFT OUTER JOIN clause.
● SQL RIGHT OUTER JOIN creates a result table and includes into it all the
records from the right table and only matching rows from the left table.
● SQL SELF JOIN joins the table to itself and allows comparing rows within
the same table.
Q1)Inner join.
Q2)Left join.
select* from student_info as s left join course as c on
s.student_id=c.student_id;
Q3)Right join.
select* from student_info as s right join course as c on
s.student_id=c.student_id;
LAB - 18
SQL QUERIES TO CREATE VIEWS
Advantages of view
• Restrict the access of a table so that nobody can insert the rows
into the table and only specific columns and data will be displayed.