PART A
Run the data set in Oracle Live SQL
An error might occur on the drop statements at the start of the execution but ignore that.
Reason: The first lines of the file DROP xxx are put there to in case you run the program more than once make sure that all tables are visible and contain data.
Once you have the data set up and running you will find a number of tables.
PART B
Provide a list of courses by course ID and name intro etc. and the number of students who took each course. The table is requested by an Administrator, who is not familiar with databases. Hence it is required that the tables are arranged for easy reading.
Which tables have the information we require to provide the list requested? Give the table names point
Once you have merged those tables HINT: use INNER JOIN use SQL query to find a new table where the sharedfcolumn is CNO. Give the SQL command you used to create this table. point
However, the course information is repeated for each student. We actually just want the number of students per course. When we see a sentence with "number", "per", "sum", "average" we know that we need to perform two actions: point
group data that matches on some value
perform an arithmetic or statistical operation on the group
For we need to remove the duplicates to put the data into sets HINT: use GROUP BY for we need to count the number of students HINT: use COUNTCOL
We now have almost enough information, but we also want the course name, which we know is available as it is a column in the table in the previous step. We need to add this column
drop table Reg;
drop table Student;
drop table Course;
REM Now create all the tables.
create table Studentsid char primary key,
sname yarchar not null, gpa float, major char dob DATE;
create table Coursecno char primary key,
cname yarchar not null, credits int, dept char;
create table Reg siid references Studentsidd on delete cascade,
cno references Coursecnos on delete cascade,
grade char
primary key
sid cnoo;
REM Now insert all the rows.
insert into Student values 'Joe', 'MIS', AUG if
insert into Student values 'Jack', 'MIS', JAN;
insert into Student values 'Jill', CSMAY;
insert into Student values 'Mary', CSDEC;
insert into Student values 'Peter', CSMAR;
insert into Student values 'Pat', 'Math', MAY;
insert into Student values 'Tracy', 'Math', JUL;
insert into Course valuesc 'intro', CS;
insert into Course valuesm 'database', 'Bus';
insert into Course valuesm 'programming', 'Bus';
insert into Course valuesa 'calculus', 'Math';
insert into Reg valuescA;
insert into Reg valuesmB;
insert into Reg valuesmA;
insert into Reg valuesmA;
insert into Reg valuesmB;
insert into Reg valuescA;
insert into Reg valuesmC;
insert into Reg valuesmB;
insert into Reg valuesCB;
insert into Reg valuesmA;
insert into Reg valuesmA;
insert into Reg valuescA;