Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 4 - SQL: Join, Integrity Rules 1. Create a file create.sql where you create the following tables and insert all test records. Make sure

image text in transcribedimage text in transcribed

Homework 4 - SQL: Join, Integrity Rules 1. Create a file create.sql where you create the following tables and insert all test records. Make sure you have set echo on in the beginning of the file. Spool your output to create.txt. Run create.sql until there is no error. Tum in a print out of the create.txt file. Students Enrollments SNumCNum Grade 101 101 102 03 1S355 B o GPA 3.2 CNum Ctitle IS380 Database Lee 1S385 Systems Smith IS355 Telecomm Lee Andy IS 102 Btty FIN 103 Cindy IS 1.8 1S385 A 1S380 A Field definitions: SNum varchar2(3) SName varchar2(25) Major varchar2(20) CNum varchar2(8) CTitle varchar(25) Instr varchar2(25) Note a) The tables must have appropriate primary key and foreign key declaration. b) Since It is likely that you will run create.sql many times and you will run into the following problem. The first time you run it, Oracle creates the S, C, and G tables. The second time you run it, Oracle will not let you create the tables again since the tables are already in place. It is a common practice to drop the tables at first before you create them, like this: drop table enrollment; drop table course; drop table student:; create table Courses.; 2. Create a ile query agl where you write SQL code of questions question number clearly with comments. Make sure you have set echo on in the beginning of the file and spool to Please label the query.txt Run query.sql file until there is no error. Tun in a print out ofthe query.txt file. 1. Display CNum title and Grade of courses Andy took 2. Display SNum and SName of students who tookIS380. 3. Display SNum and SName of students who took IS380 and received an A'. 4. Display SNum and SName of students who are IS major and took IS380. 5. Display Snum and Sname of'IS' student who receved an 'A in IS380 6. Display SNum and SName of students who took IS380 but not an IS major. 7. Display SNum of students nho took the 'Telecomm course. 8. Display SNum of students who received an 'A from any of Lee's class. 9. Display SNum and SName of students whose GPA is less than 2 but received an 'A in Lee's class. 10. Display SNum and SName of students who hae Lee as an instructor

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions