0% found this document useful (0 votes)
65 views7 pages

Dbms Lab Midterm: Akshay Harish 20191ISE0008 4ISE1

1. The document describes creating tables, populating data, and performing queries on a database for a student project management system. Tables are created for guides, students, projects, groups, and a joining table. The tables are populated with sample data. 2. Views and queries are written to list student, project, and guide details; find guides managing more than two groups; and filter projects by domain. 3. The guide for a student is updated, and a guide is removed by changing their ID in related records.

Uploaded by

Akshay Harish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views7 pages

Dbms Lab Midterm: Akshay Harish 20191ISE0008 4ISE1

1. The document describes creating tables, populating data, and performing queries on a database for a student project management system. Tables are created for guides, students, projects, groups, and a joining table. The tables are populated with sample data. 2. Views and queries are written to list student, project, and guide details; find guides managing more than two groups; and filter projects by domain. 3. The guide for a student is updated, and a guide is removed by changing their ID in related records.

Uploaded by

Akshay Harish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DBMS LAB

MIDTERM

AKSHAY HARISH
20191ISE0008
4ISE1
1.Create the tables for the above schema specifying appropriate data type for each
attribute and enforcing primary key, foreign key constraints, unique, not null where ever
required.(Note: table name must be rollno_tablename)
mysql> CREATE TABLE 20191ISE0008_GUIDE(
-> GUIDE_NAME VARCHAR(20),
-> GUIDE_NO INT(6) PRIMARY KEY NOT NULL,
-> GUIDE_RESEARCH_DOMAIN VARCHAR(20),CONTACT_NO INT(10),
-> EMAIL_ID VARCHAR(50));
Query OK, 0 rows affected, 2 warnings (0.07 sec)

mysql> CREATE TABLE 20191ISE0008_STUDENT(


-> ROLL_NO INT(10) PRIMARY KEY NOT NULL,
-> NAME VARCHAR(30),SEM INT, DEGREE VARCHAR(20),
-> CONTACT_NUMBER INT(10),GUIDE_NO INT(6),
-> FOREIGN KEY (GUIDE_NO) REFERENCES 20191ISE0008_GUIDE(GUIDE_NO));
Query OK, 0 rows affected, 3 warnings (0.04 sec)

mysql> CREATE TABLE 20191ISE0008_PROJECT(


-> PROJECT_NO INT(10) PRIMARY KEY NOT NULL,
-> PROJECT_TITLE VARCHAR(20),PROJECT_AREA VARCHAR(20),
-> START_DT DATE,GUIDE_NO INT(6),
-> FOREIGN KEY (GUIDE_NO) REFERENCES 20191ISE0008_GUIDE(GUIDE_NO));
Query OK, 0 rows affected, 2 warnings (0.04 sec)

mysql> CREATE TABLE 20191ISE0008_GROUP(


-> GROUP_CODE INT(10) PRIMARY KEY NOT NULL,
-> ROLL_NO INT(10),
-> FOREIGN KEY(ROLL_NO) REFERENCES 20191ISE0008_STUDENT(ROLL_NO));
Query OK, 0 rows affected, 2 warnings (0.03 sec)

mysql> CREATE TABLE 20191ISE0008_PROJECT_GROUP(


-> GROUP_CODE INT(10),PROJECT_NO INT(10),NO_OF_STUDENTS INT(2),
-> FOREIGN KEY(GROUP_CODE) REFERENCES 20191ISE0008_GROUP(GROUP_CODE)ON DELETE
CASCADE,
-> FOREIGN KEY(PROJECT_NO) REFERENCES 20191ISE0008_PROJECT(PROJECT_NO)ON DELETE
CASCADE);
Query OK, 0 rows affected, 3 warnings (0.05 sec)
2.Populate the database with rich data set (Insert five rows for each table)

mysql> INSERT INTO 20191ISE0008_GUIDE VALUES


-> ('RAHUL',112210,'AGRI',99887766,'RH@GMAIL.COM'),
-> ('ROHAN',112211,'PHARMA',99637466,'RO@GMAIL.COM'),
-> ('ANEES',112212,'DATA SCIENCE',98824646,'AN@GMAIL.COM'),
-> ('KARAN',112213,'ML',99274556,'KA@GMAIL.COM'),
-> ('ISHA',112214,'AERO',95566376,'ISHA@GMAIL.COM');
Query OK, 5 rows affected (0.02 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> INSERT INTO 20191ISE0008_STUDENT VALUES
-> (110010,'HIMESH',4,'CSE',86756453,112212),
-> (110011,'ABHILASH',4,'ISE',96766463,112211),
-> (110012,'DIYA',4,'CSE',96335563,112211),
-> (110013,'ANANYA',4,'CSE',96343563,112213),
-> (110014,'RIYA',4,'ISE',96778833,112213);
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> INSERT INTO 20191ISE0008_PROJECT VALUES
-> (1,'SEEDS GROWTH','AGRI','2020-03-06',112210),
-> (2,'IRRIGATION','AGRI','2020-05-10',112210),
-> (3,'CROP YEILD','AGRI','2020-10-10',112210),
->
-> (4,'DATA SCRAPPING','DATA SCIENCE','2020-11-07',112212),
-> (5,'DATA MINING','DATA SCIENCE','2020-10-07',112212);
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> INSERT INTO 20191ISE0008_GROUP VALUES
-> (101,110010),
-> (102,110011),
-> (103,110012),
-> (104,110013),
-> (105,110014);
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> INSERT INTO 20191ISE0008_PROJECT_GROUP VALUES
-> (101,1,5),
-> (102,2,5),
-> (103,3,5),
-> (104,4,5),
-> (105,5,5);
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
3.Create a view that lists student name, project name and guide name
mysql> CREATE VIEW STUDENT_DETAILS AS SELECT S.NAME,P.PROJECT_TITLE,G.GUIDE_NO FROM
20191ISE0008_STUDENT S,20191ISE0008_GUIDE G,20191ISE0008_PROJECT P WHERE
S.GUIDE_NO=P.GUIDE_NO AND P.GUIDE_NO=G.GUIDE_NO;
Query OK, 0 rows affected (0.01 sec)

(WAS EXECUTED AT THE END HENCE THE DEVIATION IN THE VALUES)

4.Find the list of guide, who are guiding more than two student groups.
mysql> SELECT G.GUIDE_NAME FROM 20191ISE0008_GUIDE G,20191ISE0008_PROJECT
P,20191ISE0008_PROJECT_GROUP S WHERE P.GUIDE_NO=G.GUIDE_NO AND
P.PROJECT_NO=S.PROJECT_NO HAVING COUNT(*)>2;

5.Find the list of project no, project name & name of guide, in domain of DataBase.
mysql> SELECT P.PROJECT_NO,P.PROJECT_TITLE,G.GUIDE_NAME FROM 20191ISE0008_PROJECT
P,20191ISE0008_GUIDE G WHERE P.GUIDE_NO=G.GUIDE_NO;

6.Update guide details of a roll no “110011”, new guide is “Ram Mohan‟ & id “112200‟.
mysql> UPDATE 20191ISE0008_GUIDE SET GUIDE_NAME="RAM MOHAN" WHERE GUIDE_NO=112214;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> UPDATE 20191ISE0008_GUIDE SET GUIDE_NO=112200 WHERE GUIDE_NO=112214;


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

7.Remove the Guide details, guide no is “112211” and assign guide no “133113” to all
respective students project group.
mysql> UPDATE 20191ISE0008_GUIDE SET GUIDE_NO=133113 WHERE GUIDE_NO=112211;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy