0% found this document useful (0 votes)
26 views

Lab2 RDBMS

The document creates and populates multiple tables in a company database including tables for employees, departments, project works, and employee dependents. It inserts data into each table and runs some select queries to view the populated data.

Uploaded by

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

Lab2 RDBMS

The document creates and populates multiple tables in a company database including tables for employees, departments, project works, and employee dependents. It inserts data into each table and runs some select queries to view the populated data.

Uploaded by

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

show databases;

use company;
create database company;
use company;
create table employee(SSN int(9) not null, Fname char(15) not null, minit char,
lname char(20),
address varchar(40), DOB date, sex char, Salary decimal(10,2),Dno int (2),
super_ssn int(9), primary key(SSN));
desc employee;
insert into employee values(123456789, 'John', 'B', 'Smith', '730 Fondren, Houston,
TX', '1965-09-12', 'M', 30000, 5, 333457956);
insert into employee values(333445555, 'Franklin', 'T', 'Wong', '638 Voss, Houston,
TX', '1955-12-08', 'M', 40000, 5, 888665555);
insert into employee values(999887777, 'Alicia', 'J', 'Zelaya', '3321 Castle,
Spring, TX', '1968-01-19', 'F', 25000, 4, 987654321);
insert into employee values(987654321, 'Jennifer', 'S', 'Wallace', '291 Berry,
Bellaire, TX', '1941-06-20', 'F', 43000, 4, 888665555);
insert into employee values(666884444, 'Ramesh', 'K', 'Narayan', '975 Fire Oak,
Humble, TX', '1962-09-15', 'M', 38000, 5, 333445555);
insert into employee values(453453453, 'Joyce', 'A', 'English', '5631 Rice,
Houston, TX', '1972-07-31', 'F', 25000, 5, 333445555);
insert into employee values(987987987, 'Ahmad', 'V', 'Jabbar', '980 Dallas,
Houston, TX', '1969-03-29', 'M', 25000, 4, 987654321);
insert into employee values(888665555, 'James', 'E', 'Borg', '450 Stone, Houston,
TX', '1931-11-10', 'M', 55000, 1, NULL);
select * from employee;
create table department(Dname varchar(20), Dnumber int(2) not null, Mgr_ssn
int(10), Mgr_start_date date, primary key(Dnumber));
insert into department values('Research', 5, 333445555, '1988-05-22');
insert into department values('Administration', 4, 987654321, '1955-01-01');
insert into department values('Headquarters', 1, 888665555, '1981-06-19');
select * from department;
create table dept_locations(Dnumber int(2) not null, Dlocation varchar(15) not
null);
insert into dept_locations values(1, 'Houston');
insert into dept_locations values(4, 'Stafford');
insert into dept_locations values(5, 'Bellaire');
insert into dept_locations values(5, 'Sugarland');
insert into dept_locations values(5, 'Houston');
select * from dept_locations;
create table works_on(Essn int(10) not null, Pnumber int(2) not null, Hours
decimal(3,1));
insert into works_on values(123456789, 1, '32.5');
insert into works_on values(123456789, 2, '7.5');
insert into works_on values(123456789, 1, '32.5');
insert into works_on values(666884444, 3, '40.0');
insert into works_on values(453453453, 1, '20.0');
insert into works_on values(453453453, 2, '20.0');
insert into works_on values(333445555, 2, '10.0');
insert into works_on values(333445555, 3, '10.0');
insert into works_on values(333445555, 10, '10.0');
insert into works_on values(333445555, 20, '10.0');
insert into works_on values(999887777, 30, '30.0');
insert into works_on values(999887777, 10, '15.0');
insert into works_on values(987987987, 10, '35.0');
insert into works_on values(987987987, 30, '5.0');
insert into works_on values(987654321, 30, '20.0');
insert into works_on values(987654321, 20, '15.0');
insert into works_on values(888665555, 20, '0.0');
select * from works_on;
create table project(Pname char(15), Pnumber int(2) not null, Plocation char(15),
Dnum int(2), primary key(Pnumber));
insert into project values('Product X', 1, 'Bellaire', 5);
insert into project values('Product Y', 2, 'Sugarland', 5);
insert into project values('Product Z', 3, 'Houston', 5);
insert into project values('Computerization', 10, 'Stafford', 4);
insert into project values('Reorganization', 20, 'Houston', 1);
insert into project values('New Benefits', 30, 'Stafford', 4);
select * from project;
create table dependent(Essn int(10) not null, Dependent_name char(15) not null, Sex
char, Bdate date, Relationship char(15));
insert into dependent values(333445555, 'Alice', 'F', '1986-04-05', 'Daughter');
insert into dependent values(333445555, 'Theodore', 'M', '1983-10-25', 'Son');
insert into dependent values(333445555, 'Joy', 'F', '1958-05-03', 'Spouse');
insert into dependent values(987654321, 'Abner', 'M', '1942-02-28', 'Spouse');
insert into dependent values(123456789, 'Michael', 'M', '1988-01-04', 'Son');
insert into dependent values(123456789, 'Alice', 'F', '1988-12-30', 'Daughter');
insert into dependent values(123456789, 'Elizabeth', 'F', '1967-05-05', 'Spouse');
select * from dependent;

You might also like