Dbmslab2
Dbmslab2
Experiment Number 2
Experiment Title Data Definition Languages
Date of Experiment 31/01/2024
Date of Submission 13/02/2024
1. Problem Statement:
1. Use SQL statements to create the following tables in College Student Database. Define
NOT NULL DEFAULT, UNIQUE, and CHECK constraints wherever appropriate.
a) STUDENT (StudentId, Last, First, Street, City, State, Zip, StartTerm, BirthDate,
FacultyId, MajorId, Phone);
b) FACULTY (FacultyId, Name, RoomId, Phone, DeptId); COURSE (CourseId,
Title, Credits, PreReq);
c) CRSSECTION (CsId, CourseId, Section, TermId, FacultyId, Day, StratTime,
EndTime, RoomId, MaxCount);
d) TERM (TermId, TermDesc, StartDate, EndDate); ROOM (RoomType,
RoomDesc);
e) REGISTRATION (StudentId, CsId, Midterm, Final, RegStatus);
f) DEPARTMENT (DeptId, DeptName, FacultyId); MAJOR (MajorId, MajorDesc);
g) LOCATION (RoomId, Building, RoomNo, Capacity, RoomType).
Insert minimum 5 records in each table.
2. Use SQL statements to create the following tables in Corporation Employee Database.
Define NOT NULL DEFAULT, UNIQUE, and CHECK constraints wherever appropriate.
2. Theory:
The Data Definition Language (DDL) in SQL is responsible for defining and
managing the structure of a database. It includes commands like CREATE for
creating tables, indexes, and views, specifying data types and constraints. DDL also
allows modifications and deletions of database objects, ensuring tegrity and
providing a foundation for efficient data storage and retrieval
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
INSERT INTO student (student_id, last_name, first_name, city, state, zip, start_term,
Birth_date, faculty_id, major_id, phone)
VALUES
(1, 'Smith', 'John', 'New York', 'NY', 10001, 2022, '2000-01-01', 101, 201, 1234567890),
(2, 'Johnson', 'James', 'Los Angeles', 'CA', 90001, 2022, '2000-02-02', 102, 202, 2345678901),
(3, 'Williams', 'Robert', 'Chicago', 'IL', 60007, 2022, '2000-03-03', 103, 203, 3456789012),
(4, 'Brown', 'Michael', 'Houston', 'TX', 77001, 2022, '2000-04-04', 104, 204, 4567890123),
(5, 'Jones', 'William', 'Phoenix', 'AZ', 85001, 2022, '2000-05-05', 105, 205, 5678901234);
create table faculty(faculty_id int , name varchar(20), room_id int, phone int, dept_id int);
alter table faculty modify column phone long;
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
create table course (course_id int ,title varchar(20), credit int, pre_req varchar(20));
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
INSERT INTO crssection (cs_id, course_id, section, term_id, faculty_id, day, start_time,
end_time, room_id, max_count)
VALUES
(1, 101, 'A', 2022, 101, '2022-01-01', '08:00:00', '10:00:00', 101, 30),
(2, 102, 'B', 2022, 102, '2022-01-02', '10:00:00', '12:00:00', 102, 25),
(3, 103, 'C', 2022, 103, '2022-01-03', '12:00:00', '14:00:00', 103, 20),
(4, 104, 'D', 2022, 104, '2022-01-04', '14:00:00', '16:00:00', 104, 35),
(5, 105, 'E', 2022, 105, '2022-01-05', '16:00:00', '18:00:00', 105, 40);
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
use corporation;
Create table employee( employee_id INT not null primary key, lname VARCHAR(20),
fname VARCHAR(20), position_id INT,supervisor VARCHAR(20), hire_date DATE,
salary FLOAT, commission FLOAT, dept_id INT, qual_id INT);
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Create table dependent( employee_id INT, dependent_id INT, dep_dob DATE, relation
VARCHAR(20));
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
4. Concluding Remarks:
The Data Definition Language (DDL) in SQL is responsible for defining and
managing the structure of a database. It includes commands like CREATE for
creating tables, indexes, and views, specifying data types and constraints.
DDL also allows modifications and deletions of database objects, ensuring
data integrity and providing a foundation for efficient data storage and
retrieval.
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering
Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030