Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CMPS 277 Database Systems Spring 2018-2019

SQL Lab, Session 1 Section 3

Consider a laboratory database that is used to keep track of labs and technicians. The database
has two tables only, one for technicians called TECHNICIAN and a second one for the labs and is
called LAB. The two tables are summarized below.

TECHNICIAN has the following columns:

tno INT NOT NULL


tname VARCHAR(10) NOT NULL
tjob VARCHAR(10) NOT NULL
tmgr INT ALLOWS NULL
thiredate DATE NOT NULL
tsalary INT NOT NULL
tbonus INT NULL
tlno INT NOT NULL

and LAB has the following columns:

lno INT NOT NULL


lname VARCHAR(10) NOT NULL
llocation VARCHAR(10) NOT NULL

The primary key of TECHNICIAN is tno and that of LAB is lno. There are two foreign keys:
TECHNICIAN.tlno that references LAB and TECHNICIAN.tmgr that references TECHNICIAN. The
TECHNICIAN.tmgr holds tno of the manager for a technician.

Perform each of the following tasks using MySQL. Create an SQL script to keep track of your
solutions and copy and paste the SQL statements you executed to perform each of the following
tasks in your SQL script. Moreover, copy and paste the output of your SQL statements (if any)
in a separate text file. Upload both your SQL script and the results text file on Moodle.
(a) Create the above database in MySQL and call it LABORATORY.

(b) Insert the following tuples in the LAB table:

(10, ’King Wood Lab’, ’New York’);


(20, ’Happiness Lab’, ’Dallas’);
(30, ’Checklist Lab’, ’Chicago’);
(40, ’Saint Peters Lab’, ’Boston’);

(c) Insert the following tuples in the TECHNICIAN table:

(7839, ’King’, ’President’, NULL, ’17 NOV 2003’, 6500, 0, 10);


(7566, ’Jones’, ’Director’, 7839, ’2 APR 2003’, 3375, 0, 20);
(7698, ’Blake’, ’Director’, 7839, ’1 MAY 2003’, 3250, 0, 30);
(7782, ’Clark’, ’Director’, 7839, ’9 JUN 2003’, 2850, 0, 10);
(7499, ’Allen’, ’Head Technician’, 7698, ’20 FEB 2003’, 2000, 500, 30);
(7521, ’Ward’, ’Head Technician’, 7698, ’22 FEB 2003’, 1650, 800, 30);
(7654, ’Martin’, ’Head Technician’, 7698, ’28 SEP 2003’, 1650, 1400, 30);
(7844, ’Turner’, ’Head Technician’, 7698, ’8 SEP 2003’, 1900, 0, 30);
(7900, ’James’, ’Assistant Technician’, 7698, ’3 DEC 2003’, 1350, 0, 30);
(7788, ’Scott, ’Technician’, 7566, ’27 JUN 2002’, 3500, 0, 20);
(7902, ’Ford’, ’Technician’, 7566, ’3 DEC 2003’, 3500, 0, 20);
(7369, ’Smith’, ’Assistant Technician’, 7902, ’17 DEC 2002’, 1200, 0, 20);
(7876, ’Adams’, ’Assistant Technician’, 7788, ’31 JUL 2002’, 1500, 0, 20);
(7934, ’Miller’, ’Assistant Technician’, 7782, ’23 JAN 2003’, 1700, 0, 10);

You might also like