You are on page 1of 3

LIST OF EXPERIMENTS:

1. Explain following in short : Tuple, Entity, Attribute, Primary key, ER Diagram


2. Explain the roll of DBA
3. Create a database COLLEGE and create following tables:
 Student(sid, fname,mname,lname,city,pin,mobile,br_id)
(mobile and mname can be NULL)
CREATE TABLE Student (
sid INT PRIMARY KEY,
fname VARCHAR(50) NOT NULL,
mname VARCHAR(50),
lname VARCHAR(50) NOT NULL,
city VARCHAR(50) NOT NULL,
pin VARCHAR(10) NOT NULL,
mobile VARCHAR(10),
br_id INT,
FOREIGN KEY (br_id) REFERENCES Branch (bid)
);
 Branch (bid,bcode,bname)
CREATE TABLE Branch (
bid INT PRIMARY KEY,
bcode VARCHAR(10) NOT NULL,
bname VARCHAR(50) NOT NULL
);
 Result(rid,student_id, marks)
(check constraint on marks <=100)
with foreign key br_id and student_id
CREATE TABLE Result (
rid INT PRIMARY KEY,
student_id INT,
marks INT CHECK (marks <= 100),
FOREIGN KEY (student_id) REFERENCES Student (sid)
);
4. Insert atleast 10 records recrods in each table.
INSERT INTO Student (sid, fname, mname, lname, city, pin, mobile, br_id)
VALUES (1, 'John', NULL, 'Doe', 'New York', '12345', '9876543210', 1),
(2, 'Jane', 'Maria', 'Smith', 'Los Angeles', '67890', '9876543211', 2),
(3, 'Michael', 'James', 'Johnson', 'Chicago', '54321', NULL, 1),
(4, 'Sarah', 'Ann', 'Williams', 'Houston', '67891', '9876543212', 3),
(5, 'David', 'John', 'Brown', 'San Francisco', '54322', NULL, 2),
(6, 'Olivia', 'Grace', 'Taylor', 'Miami', '67892', '9876543213', 1),
(7, 'Daniel', 'William', 'Clark', 'Boston', '54323', '9876543214', 2),
(8, 'Sophia', NULL, 'Anderson', 'Seattle', '67893', NULL, 3),
(9, 'Matthew', 'Thomas', 'White', 'Dallas', '54324', '9876543215', 1),
(10, 'Ava', 'Elizabeth', 'Lee', 'San Diego', '67894', '9876543216', 2);
INSERT INTO Branch (bid, bcode, bname)
VALUES (1, 'CSE', 'Computer Science and Engineering'),
(2, 'EEE', 'Electrical and Electronics Engineering'),
(3, 'MECH', 'Mechanical Engineering'),
(4, 'CIVIL', 'Civil Engineering'),
(5, 'MCE', 'Materials and Metallurgical Engineering'),
(6, 'CHEM', 'Chemical Engineering'),
(7, 'MATH', 'Mathematics'),
(8, 'PHY', 'Physics'),
(9, 'CHEM', 'Chemistry'),
(10, 'BIO', 'Biology');
INSERT INTO Result (rid, student_id, marks)
VALUES (1, 1, 95),
(2, 2, 88),
(3, 3, 78),
(4, 4, 92),
(5, 5, 85),
(6, 6, 79),
(7, 7, 90),
(8, 8, 91),
(9, 9, 87),
(10, 10, 82);
5. Write SQL Query for adding colume “Description” to Department.
ALTER TABLE Department
ADD COLUMN Description VARCHAR(255);
6. Update city name from “Hoshangabad” to “Narmadapuram” for all students belonging to
Hoshangabad
UPDATE Students
SET City = 'Narmadapuram'
WHERE City = 'Hoshangabad';
7. Find fname,lname of all students belonging to Indore
SELECT fname, lname
FROM Students
WHERE City = 'Indore';
8. Find name of all students whose name starts with “aa”
SELECT Name
FROM Students
WHERE Name LIKE 'aa%';
9. Find name of all students who did not have mobile number.
SELECT Name
FROM Students
WHERE MobileNumber IS NULL;
10. Find id of top 10 students.
SELECT ID
FROM Students
ORDER BY Marks DESC
LIMIT 10;
11. Find name of top 5 students.
SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Students
ORDER BY Marks DESC
LIMIT 5;

12. Select all students Order by their marks in Descending order


SELECT *
FROM Students
ORDER BY Marks DESC;
13. Find number of all students belonging to different cities.
SELECT City, COUNT(*) AS NumberOfStudents
FROM Students
GROUP BY City;

14. Write queries to find max, min and avg marks and total number of records in to Student
table.
SELECT MAX(Marks) AS MaxMarks
FROM Students;
SELECT MIN(Marks) AS MinMarks
FROM Students;
SELECT AVG(Marks) AS AvgMarks
FROM Students;
SELECT COUNT(*) AS TotalRecords
FROM Students;
15. Study of open source ERP
16. Study of cloud ERP
17. Design of Supply Chain Management Model.

You might also like