Question

In: Computer Science

After reviewing the various ERDs, Trinity University has decided on the following tables and columns. Primary...

After reviewing the various ERDs, Trinity University has decided on the following tables and columns. Primary key fields are highlighted in red.

PLEASE USE MYSQL WORBENCH AND SCREEN SHOT

Base Tables:

PROFESSOR

ProfID

ProfSpecialty

ProfRank

ProfLName (NN)

ProfFName (NN)

ProfInitial

ProfEmail

DEPARTMENT

DeptID

DeptName (NN)

COURSE

CourseID

CourseTitle (NN)

CourseDescription

CourseCredits

STUDENT

StudentID

StudentLName (NN)

StudentFName (NN)

StudentInitial

StudentEmail

Tables with Foreign Keys:

DEPTCHAIR

ProfessorID

DeptID

STUDENTDEPT

StudentID

DeptID

ADVISOR

ProfessorID

StudentID

COURSEDEPT

CourseID

DeptID

CLASS

ClassID

CourseID

ProfID

ClassSection

ClassDays

ClassTime

ENROLL

Student ID

CourseID

ClassID

EnrollmentDate (NN)

Grade (NN)

Write the SQL code to drop and then create the above tables. Remember that when creating tables, the tables with foreign keys have to be created after the table that the foreign key points to. When dropping tables, they have to be dropped in the reverse order, so that the tables with foreign keys are dropped before the tables that the foreign keys point to. You can create all the drop SQL statements first followed by all the create tables. The first time you run them the drop statements will work as no tables have been created and therefore no drops will occur. You will need to run them twice to insure the drops will work.

All primary key fields and fields marked as (NN) are required fields, all others are optional. Use appropriate data types for each column.

I am trying to do but it doesnt work

DROP TABLE IF EXISTS PROFESSOR;
DROP TABLE IF EXISTS DEPARTMENT;
DROP TABLE IF EXISTS COURSE;
DROP TABLE IF EXISTS STUDENT;
DROP TABLE IF EXISTS DEPTCHAIR;
DROP TABLE IF EXISTS STUDENTDEPT;
DROP TABLE IF EXISTS ADVISOR;
DROP TABLE IF EXISTS COURSEDEPT;
DROP TABLE IF EXISTS CLASS;
DROP TABLE IF EXISTS ENROLL;

CREATE TABLE IF NOT EXISTS PROFESSOR
(
Prof_ID int PRIMARY KEY,
Prof_Speciality varchar(20),
Prof_Rank int,
Prof_LName varchar(20),
Prof_FName varchar(20),
Prof_Initial varchar(20),
Prof_Emai varchar
);

Solutions

Expert Solution

Answer:

CREATE TABLE PROFESSOR(
ProfID int,
ProfSpecialty varchar(15),
ProfRank varchar(5),
ProfLName varchar(15) NOT NULL,
ProfFName varchar(15) NOT NULL,
ProfInitial varchar(10),
ProfEmail varchar(20),
PRIMARY KEY(ProfID));


CREATE TABLE DEPARTMENT(
DeptID int,
DeptName varchar(15) NOT NULL,
PRIMARY KEY(DeptID));

CREATE TABLE COURSE(
CourseID int,
CourseTitle varchar(10) NOT NULL,
CourseDescription varchar(20),
CourseCredits decimal(4,2),
PRIMARY KEY(CourseID));

CREATE TABLE STUDENT(
StudentID int,
StudentLName varchar(10) NOT NULL,
StudentFName varchar(10) NOT NULL,
StudentInitial varchar(10),
StudentEmail varchar(20),
PRIMARY KEY(StudentID));

CREATE TABLE DEPTCHAIR(
ProfessorID int,
DeptID int,
PRIMARY KEY(ProfessorID, DeptID),
FOREIGN KEY (ProfessorID) REFERENCES PROFESSOR(ProfID),
FOREIGN KEY (DeptID) REFERENCES DEPARTMENT(DeptID));

CREATE TABLE CLASS(
ClassID int,
CourseID int,
ProfID int,
ClassSection varchar(10),
ClassDays int,
ClassTime varchar(10),
PRIMARY KEY(ClassID, CourseID,ProfID),
FOREIGN KEY (CourseID) REFERENCES COURSE(CourseID),
FOREIGN KEY (ProfID) REFERENCES PROFESSOR(ProfID));

CREATE TABLE STUDENTDEPT(
StudentID int,
DeptID int,
PRIMARY KEY(StudentID, DeptID),
FOREIGN KEY (StudentID) REFERENCES STUDENT(StudentID),
FOREIGN KEY (DeptID) REFERENCES DEPARTMENT(DeptID));

CREATE TABLE ENROLL(
StudentID int,
CourseID int,
ClassID int,
EnrollmentDate date NOT NULL,
Grade varchar(4) NOT NULL,
PRIMARY KEY(StudentID,CourseID, ClassID),
FOREIGN KEY (StudentID) REFERENCES STUDENT(StudentID),
FOREIGN KEY (CourseID) REFERENCES COURSE(CourseID),
FOREIGN KEY (ClassID) REFERENCES CLASS(ClassID));

CREATE TABLE ADVISOR(
ProfessorID int,
StudentID int,
PRIMARY KEY(ProfessorID,StudentID),
FOREIGN KEY (ProfessorID) REFERENCES PROFESSOR(ProfID),
FOREIGN KEY (StudentID) REFERENCES STUDENT(StudentID));

CREATE TABLE COURSEDEPT(
CourseID int,
DeptID int,
PRIMARY KEY(CourseID,DeptID),
FOREIGN KEY (CourseID) REFERENCES COURSE(CourseID),
FOREIGN KEY (DeptID) REFERENCES DEPARTMENT(DeptID));


DROP TABLE IF EXISTS DEPTCHAIR;
DROP TABLE IF EXISTS STUDENTDEPT;
DROP TABLE IF EXISTS ADVISOR;
DROP TABLE IF EXISTS COURSEDEPT;
DROP TABLE IF EXISTS ENROLL;
DROP TABLE IF EXISTS CLASS;
DROP TABLE IF EXISTS PROFESSOR;
DROP TABLE IF EXISTS DEPARTMENT;
DROP TABLE IF EXISTS COURSE;
DROP TABLE IF EXISTS STUDENT;

Screenshot:


Related Solutions

After carefully reviewing the company’s current financial situation, management team has decided to review the Proposed...
After carefully reviewing the company’s current financial situation, management team has decided to review the Proposed budget for year 2 and you are requested to prepare revised budget in accordance with organisational budgetary requirements for year 2 & 3. Use appropriate software to prepare the budget and then attach it to this assessment tool. My retail Business Budgeted Income Statement For year ended 30 June 2017 Year 1 $ Revenue Sales 458,580 less TOTAL COST OF GOODS SOLD 334,764 GROSS...
After reviewing the case for Nature Bros. Ltd., answer the following questions. After reviewing this material,...
After reviewing the case for Nature Bros. Ltd., answer the following questions. After reviewing this material, make a list of additional information which should be supplied to support the sales projections. Comment on objectives: Are they reasonable, optimistic, or conservative? What marketing mix would best support this growth rate? Evaluate the information supplied regarding a new product development and physical assets in light of the pro forma income statements Morris developed. Is the capital sought appropriate for the circumstances? If...
After several years of internal debate, the Stieg Primary Group has decided to offer a walk-in...
After several years of internal debate, the Stieg Primary Group has decided to offer a walk-in clinic for patients. Many of the physicians were not happy with the change as t meant that one day a week ,one of the physicians in the group wuld be responsible for staffing the clinic's early hour opening , which brgan at 7:30 a.m and ( 90 minutes before the office 's regular 9:00 a.m. offering) The physician was supported by a nursre practitioner...
After reviewing the various theories of nursing, reflect on your personal philosophy of nursing. Discuss the...
After reviewing the various theories of nursing, reflect on your personal philosophy of nursing. Discuss the major theorists who influenced you and identify the elements you incorporate into your philosophy.     
Ryan and Robin met at Rockhurst university and after graduation in 2020; they decided to form...
Ryan and Robin met at Rockhurst university and after graduation in 2020; they decided to form a business to market American flags, “buy American” bumper stickers, and other similar merchandise. The merchandise would be manufactured in China and sold initially only in Missouri. Ryan wants to operate the business as a partnership; while Robin wants to organize the business as a regular C corporation. Limit your answers for the first two question to these two business forms (3 points each)...
Summarize the Patient Bill of Rights After reviewing your textbook and various websites, please summarize the...
Summarize the Patient Bill of Rights After reviewing your textbook and various websites, please summarize the Patient Bill of Rights and include the following: choice of treatment, consent for treatment and refusal of treatment. Websites should include local hospital/health systems, included on your citation/reference listing.   Here is a link to the Michigan government webpage: http://www.legislature.mi.gov/(S(idzg4lw5w1o1rsh0pb1o0qe3))/mileg.aspx?page=getObject&objectname=mcl-333-20201 PreviousNext
Tables 7.14 and 7.15 show the survival 50 years after graduation of men and women who graduated each year from 1938 to 1947 from various faculties of the University of Adelaide
Table 7.14:Fifty years survival for men after graduation from the University of Adelaide                                                                            Faculty Years of graduation Medicine S     T Arts S   T Science S   T Engineering S   T 1938 18   22 16   30 9   14 10   16 1939 16   23 13   22 9   12 7   11 1940 7   17 11   25 12   19 12   15 1941 12   25 12   14 12   15 8   9 1942 24   50 8   12 20   28 5   7 1943 16   21 11   20 16  ...
After graduating from this university you have decided to establish a contractorship company to do some...
After graduating from this university you have decided to establish a contractorship company to do some building constructions. Your first job is to construct 10 similar reinforced concrete buildings with four stories each. The total area of all the buildings is 16,000m2 . You can find sufficient number of formwork carpenters to erect any kind of formwork materials. On the market both timber and steel formwork materials are available. •Make an analysis on which type of materials you are going...
Maria Gutierrez and Devin Duzan recently graduated from the same university. After graduation they decided not...
Maria Gutierrez and Devin Duzan recently graduated from the same university. After graduation they decided not to seek jobs at established organizations but, rather, to start their own small business hoping they could have more flexibility in their personal lives for a few years. Maria’s family has operated Mexican restaurants and taco trucks for the past two generations, and Maria noticed there were no taco truck services in the town where their university was located. To reduce the amount they...
Renee Carter has decided to study medicine at a university in Melbourne. She has arranged to...
Renee Carter has decided to study medicine at a university in Melbourne. She has arranged to stay with a family on the north side of the city. In order to get to and from the university, she decides she will need to buy a car, costing a maximum of $10 000. She searches the Internet and comes across the following at Car City: MAZDA 323 Red, 4D Sedan; 5 SP Manual; 2.0 Ltr, 4 cycl; odometer 153 293. Required ?A....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT