Use the code provided to create the tables. Turn in a hard copy of HW. The table
ID: 3704942 • Letter: U
Question
Use the code provided to create the tables. Turn in a hard copy of HW. The table creation code must be at the top of the script, followed by the modifications and inserts. NOTE: you must insert the data in the correct order, which may not be the order given in the HW.
please run the codes on the sql manager to make sure it runs in order for me to give you the credit
i've included the code/file we need to do the homework.
SQL
SQL MANAGER
NOTEPAD ++
Explanation / Answer
Answer 2)
CREATE TABLE student
(
student_id INT PRIMARY KEY,
s_first VARCHAR (30),
s_mi CHAR(1),
s_last VARCHAR(30),
s_class CHAR(2),
s_dob DATETIME,
s_major VARCHAR(22),
s_gpa NUMERIC(3,2),
f_id INT,
FOREIGN KEY (f_id) REFERENCES faculty(f_id)
);
Added foreign key constraint in the table student for the relationship.
CREATE TABLE faculty(
f_id INT PRIMARY KEY,
f_first VARCHAR(30),
f_last VARCHAR(30),
f_salary MONEY,
year_hired INT,
phd BIT
);
Answer 3)
ALTER TABLE student
DROP COLUMN s_major;
Altering the table student to drop the column s_major.
Answer 4)
Insert data into faculty table:
insert into faculty values (14,'Ralph','A. Brooks',78000,1999,1);
insert into faculty values (22,'Jane','E. Seymour',null,2002,0);
insert into faculty values (29,'James','Bordy',56000,1996,1);
insert into faculty values (71,'Mary','Tessman',97000,2002,1);
insert into faculty values (44,'Bobby','Bell',69500,1999,0);
Insert data into student table:
insert into student values (111,'Maybelle','','Easton JR','','1984-07-01',null,29);
insert into student values (151,'Peter','','A Billings(SR)','','1986-11-03',3.3,44);
insert into student values (171,'John','','C. Briggs (FR)','','1987-05-18',null,71);
insert into student values (144,'Peggy','','Ming (JR)','',null,3.62,29);
insert into student values (166,'Abby','','M Lehmann JR','','1984-08-02',4.0,22);
select * from student;
Output:
student_id s_first s_mi s_last s_class s_dob s_gpa f_id
111 Maybelle Easton JR 1984-07-01T00:00:00Z (null) 29
144 Peggy Ming (JR) (null) 3.62 29
151 Peter A Billings(SR) 1986-11-03T00:00:00Z 3.3 44
166 Abby M Lehmann JR 1984-08-02T00:00:00Z 4 22
171 John C. Briggs (FR) 1987-05-18T00:00:00Z (null) 71
select * from faculty;
Output:
f_id f_first f_last f_salary year_hired phd
14 Ralph A. Brooks 78000 1999 true
22 Jane E. Seymour (null) 2002 false
29 James Bordy 56000 1996 true
44 Bobby Bell 69500 1999 false
71 Mary Tessman 97000 2002 true
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.