Question

In: Computer Science

the college wants to keep track of the semester schedules across years. i.e. Departments, their Courses...

the college wants to keep track of the semester schedules across years. i.e. Departments, their Courses as they exist in the College catalog, and the course section offerings across the years and their semesters. From a catalogue perspective:

A department has a unique name (Finance, Management and Marketing, Math, ABC-Law, etc.) and offers multiple courses.

A course has a unique name, which is a hyphenated prefix-Number like (BUAN-310, CIS-205, FIN315, MATH-153, etc.), a long name like “principles of Data management”, a long description and a number of credit (leave prerequisites out for now).

During any given semester (Fall, Spring, Summer-1, Summer-2, Winter), Zero-Or-More-sections of a given course are offered. For example, For BUAN-227 and for the Fall of 2019, 4 sections (1, 2, 3 and 61, I made it up) were offered.

Each section has a CRN, which is a unique identifier and a capacity to indicate the max number of students that can sign-up for the course (Leave time and room out for now).

We leave students who register for courses out for now

Your reverse engineered schema looks similar

Write the SQL code that creates the tables and enforces Primary and foreign key constraints.

Your SQL Code Goes Below:


#All Fields are required

#It is your call if any of the fields is Unique.

use ……..; #Your database Schema Name instead

SET FOREIGN_KEY_CHECKS=0;

DROP TABLE Department CASCADE;

Create TABLE Department (

…….

);

#

DROP TABLE Course CASCADE;

CREATE TABLE Course(

…….

);

#

DROP TABLE CourseSection CASCADE;

CREATE TABLE CourseSection(

…….

);

#

SET FOREIGN_KEY_CHECKS=1;

Insert 5-Department Records into the Department table. Your SQL Code Goes Below:

Enter 10 Courses into the Course table; make sure you assign them to different departments. Your SQL Code Goes Below:

Enter 20 course-sections into the courseSection table across different years and semesters. No more than 3 course sections for a given year and a given semester. Your SQL Code Goes Below:

MY SQL workbench

Solutions

Expert Solution


NOTE - I HAVE ENTERED DATA ACCORDING TO CONSTRAINTS , BUT CHECK ON YOUR WORKBENCH AND EDIT ACCORDINGLY

BEFORE RUNNING SCRIPTS , CHECK IF DROP TABLE WORKS WELL BECAUSE ON SOME MACHINES , BEFORE CREATION OF TABLE IT THROWS ERROR.

so i will suggest run scripts step by step.

CREATE DATABSE MYCOLLEGE
USE MYCOLLEGE

SET FOREIGN_KEY_CHECKS=0;
DROP TABLE Department CASCADE;
CREATE TABLE Department

(
dept_id INT NOT NULL PRIMARY KEY,
name VARCHAR(20)
);

DROP TABLE Course CASCADE;

CREATE TABLE Course(

prefix_name VARCHAR(20) NOT NULL,
full_name VARCHAR(100),
description VARCHAR(200),
credits INT,
dept_id INT,
PRIMARY KEY (prefix_name),
FOREIGN KEY(dept_id)
REFERENCES Department(dept_id)
);

DROP TABLE CourseSection CASCADE;

CREATE TABLE CourseSection(

CRN VARCHAR(20) NOT NULL PRIMARY KEY,
Course_offered VARCHAR(20),
capacity INT,
Semester VARCHAR(20),
Year INT ,
FOREIGN KEY(Course_offered)
REFERENCES Course(prefix_name)


);

SET FOREIGN_KEY_CHECKS=1;

----- Inserts statements starts here --------------

Insert INTO Department VALUES
(
101,
"FINANCE"
) ;

Insert INTO Department VALUES
(
102,
"MANAGEMENT"
) ;

Insert INTO Department VALUES
(
103,
"MATHS"
) ;

Insert INTO Department VALUES
(
104,
"PHYSICS"
) ;

Insert INTO Department VALUES
(
105,
"GEOGRAPHY"
) ;


------------------------------------------------------------------------------------------------


INSERT INTO Course VALUES(
'FIN-213',
'FINANCE STUDIES',
'STUDYING ECONOMIC FACTORS OF COUNTRY RELATED TO FINANCE',
100,
(SELECT DEPT_ID FROM Department where name = 'FINANCE')

);

INSERT INTO Course VALUES(
'MATHS-290',
'MATHS STUDIES',
'TRIGNOMETRIC RELATIONSHIPS OF PHYSICAL THEORY',
130,
(SELECT DEPT_ID FROM Department where name = 'MATHS')

);
INSERT INTO Course VALUES(
'GEO-245',
'GEO STUDIES',
'GEOGRAPHY OF PLANET GREEN',
145,
(SELECT DEPT_ID FROM Department where name = 'GEOGRAPHY')

);
INSERT INTO Course VALUES(
'MAN-452',
'MANAGEMENT STUDIES',
'MANAGING COMPANY RESOURCES',
126,
(SELECT DEPT_ID FROM Department where name = 'MANAGEMENT')

);


INSERT INTO Course VALUES(
'MATHS-256',
'MATHS STUDIES',
'TRIGNOMETRIC RELATIONSHIPS OF DIFFERNTIAL THEORY',
130,
(SELECT DEPT_ID FROM Department where name = 'MATHS')

);


INSERT INTO Course VALUES(
'GEO-217',
' INDIAN GEOGRAPHY',
'STUDYING INDIAN SUB CONTINENT',
100,
(SELECT DEPT_ID FROM Department where name = 'GEOGRAPHY')

);
INSERT INTO Course VALUES(
'FIN-216',
'FINANCIAL ECONOMY',
'AMERICAN ECONOMIC FACTORS',
110,
(SELECT DEPT_ID FROM Department where name = 'FINANCE')

);
INSERT INTO Course VALUES(
'MAN-98',
'ACCOUNTS MANAGEMENT',
'CORPORATE ACCOUNTING',
100,
(SELECT DEPT_ID FROM Department where name = 'MANAGEMENT')

);
INSERT INTO Course VALUES(
'MATHS-562',
'INTEGERATION',
'STUDYING BLACK HOLE EQUATIONS',
180,
(SELECT DEPT_ID FROM Department where name = 'MATHS')

);
INSERT INTO Course VALUES(
'PHY-456',
'ELECTROMAGNETIC RADIATIOON',
'STUDYING EFFECTS OF UV RADIATION',
140,
(SELECT DEPT_ID FROM Department where name = 'PHYSICS')

);


---------------------------------------------------------------------------------------------------

INSERT INTO CourseSection VALUES(
'COURSE-GEO_1',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING INDIAN SUB CONTINENT' ),
40,
'SPRING',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-MATH_1',
(SELECT prefix_name FROM Course WHERE description= 'TRIGNOMETRIC RELATIONSHIPS OF PHYSICAL THEORY' ),
45,
'SPRING',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-PHY_1',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING EFFECTS OF UV RADIATION' ),
50,
'SPRING',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-GEO_2',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING INDIAN SUB CONTINENT' ),
40,
'SUMMER-1',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-MATH_2',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING BLACK HOLE EQUATIONS' ),
45,
'SUMMER-1',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_2',
(SELECT prefix_name FROM Course WHERE description= 'AMERICAN ECONOMIC FACTORS'),
50,
'SUMMER-1',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-PHY_3',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING EFFECTS OF UV RADIATION' ),
30,
'SUMMER-1',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-GEO_3',
(SELECT prefix_name FROM Course WHERE description= 'GEOGRAPHY OF PLANET GREEN' ),
45,
'SUMMER-1',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_4',
(SELECT prefix_name FROM Course WHERE description= 'AMERICAN ECONOMIC FACTORS'),
50,
'SUMMER-1',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-PHY_4',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING EFFECTS OF UV RADIATION' ),
30,
'SUMMER-2',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-GEO_5',
(SELECT prefix_name FROM Course WHERE description= 'GEOGRAPHY OF PLANET GREEN' ),
45,
'SUMMER-2',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_5',
(SELECT prefix_name FROM Course WHERE description= 'AMERICAN ECONOMIC FACTORS'),
50,
'SUMMER-2',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-MATH_6',
(SELECT prefix_name FROM Course WHERE description= 'TRIGNOMETRIC RELATIONSHIPS OF PHYSICAL THEORY' ),
40,
'WINTER',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-PHY_6',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING EFFECTS OF UV RADIATION' ),
80,
'WINTER',
2020
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_7',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING ECONOMIC FACTORS OF COUNTRY RELATED TO FINANCE'),
60,
'WINTER',
2020
);


INSERT INTO CourseSection VALUES(
'COURSE-MATH_7',
(SELECT prefix_name FROM Course WHERE description= 'TRIGNOMETRIC RELATIONSHIPS OF PHYSICAL THEORY' ),
40,
'SPRING',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-PHY_8',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING EFFECTS OF UV RADIATION' ),
80,
'SPRING',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_9',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING ECONOMIC FACTORS OF COUNTRY RELATED TO FINANCE'),
60,
'SPRING',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-GEO_9',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING INDIAN SUB CONTINENT' ),
40,
'SUMMER-1',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-MATH_11',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING BLACK HOLE EQUATIONS' ),
45,
'SUMMER-1',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_11',
(SELECT prefix_name FROM Course WHERE description= 'AMERICAN ECONOMIC FACTORS'),
50,
'SUMMER-1',
2021
);


INSERT INTO CourseSection VALUES(
'COURSE-PHY_12',
(SELECT prefix_name FROM Course WHERE description= 'STUDYING EFFECTS OF UV RADIATION' ),
30,
'SUMMER-2',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-GEO_12',
(SELECT prefix_name FROM Course WHERE description= 'GEOGRAPHY OF PLANET GREEN' ),
45,
'SUMMER-2',
2021
);

INSERT INTO CourseSection VALUES(
'COURSE-FIN_13',
(SELECT prefix_name FROM Course WHERE description= 'AMERICAN ECONOMIC FACTORS'),
50,
'SUMMER-2',
2021
);


Related Solutions

A small company is expanding into new offices spread across three buildings. To keep track of...
A small company is expanding into new offices spread across three buildings. To keep track of office furniture, computers, and printers, the company would like a database to keep track of everything. Each piece of office furniture, computer, or printer is given an identification number. Each item (which is either a piece of furniture, a computer, or a printer) is placed in a room of one of three buildings. The building manager is responsible for the items in their building....
Ava wants to use a database to keep track of the data recordsfor her insurance...
Ava wants to use a database to keep track of the data records for her insurance company and to enforce the following business policies/requirements: USE MS ACCESS TO CREATE A DATABASE & RELATIONASHIP-Every customer must be uniquely identified.-A customer can have many insurance policies.-Every insurance policy must be uniquely identified.-An insurance policy must belong to a valid customer.-Every customer must be served by a valid insurance agent (employee).-An insurance agent (employees) serves many customers.-Every insurance agent (employee) must be uniquely...
Task 2 introduction to software engineering A nursery wants to keep track of all its products,...
Task 2 introduction to software engineering A nursery wants to keep track of all its products, including plants, fountains, garden hardware (wheelbarrow, shovels etc) and also soil and sand which they sell. They buy all stock from the wholesalers. The management wants to know which staff members have been selling what, and from which wholesaler the products were purchased. There are also times when a customer returns a product for a refund, and such information should be available in the...
A gas station wants a program to keep track of sales. Your gas station sells diesel...
A gas station wants a program to keep track of sales. Your gas station sells diesel for 107.9 cents per litre and regular gas for 112.9 cents per litre. Have the user enter the type of fuel (1 = Regular gas, 2 = Diesel) and number of litres sold. Print out a total for each sale (remember fuel prices already include the GST). Once you enter a 0 for the type of fuel your program should stop and print out...
An amateur meteorologist wants to keep track of weather conditions during the past year's three -month...
An amateur meteorologist wants to keep track of weather conditions during the past year's three -month summer season and has designated each day as either rainy ('R'), cloudy ('C'), or sunny ('S'). Write a modu lar program that stores this information in a 3 x 30 array of characters, where the row indicates the month (0 = June, 1 = July, 2 = August) and the column indicates the day of the month. Note that data is not being collected...
Tony Gaddis C++ Monkey Business A local zoo wants to keep track of how many pounds...
Tony Gaddis C++ Monkey Business A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 7 array, where each row represents a different monkey and each column represents a different day of the week. The monkeys are represented by integers 1, 2, and 3; the weekdays are "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",...
A professor wants to determine whether her department should keep the requirement of college algebra as...
A professor wants to determine whether her department should keep the requirement of college algebra as a prerequisite for an Introductory Statistics course. Accordingly, she allows some students to register for the course on a pass-fail basis regardless of whether or not they have had the prerequisite. At the end of the semester, the professor compares the number of students passing or failing the class with whether or not they had algebra. Of the 70 students in the class, 30...
A daredevil college professor wants to jump across a canyon of depth 100m and width 50m...
A daredevil college professor wants to jump across a canyon of depth 100m and width 50m on his motorcycle. He uses a ramp inclined at 60 degrees to cross the canyon.The other side of the canyon is 10m lower than his side. Find the Minimum velocity, vo, that his motorcycle should have to make it safely across the canyon. If he jumps with a velocity of vo/3 find out what (x,y) position he would crash
(a). A college student is 23 years old and a recent graduate. He wants to start...
(a). A college student is 23 years old and a recent graduate. He wants to start saving for his retirement. He plans to save $2000 per year in an online stock account that pays annual return of 12%. If he sticks to the plan, how much money will he have at the age of 65? (make a time-line). (b). Suppose he starts saving for the retirement at the age of 40. If he uses the same plan above, how much...
Your sister will start college in five years. She just informed your parents that she wants...
Your sister will start college in five years. She just informed your parents that she wants to go to Georgia Southern University. It will cost $20,000 per year for four years (cost assumed to come at the beginning of each year). Anticipating her ambitions, your parents have saved already $15,000 and will continue to invest at the end of each month for the next five years. How much more will your parents have to invest each month for the next...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT