Database Management

The University of Texas at El Paso

Professor Kirs

 

SQL: Sample Problems and Exercises

 

NOTE: It does you absolutely no good to look at the answer before you attempt to answer the Questions.

 

Match the Terms on the Left with the Definitions on the Right

 

___ AVG

01.

A command which is used to allow only certain values to be entered

___ ALTER

02.

The data type which indicates that symbols are to be stored

___ AUTHORIZATION

03.

The data type which is used to store months, days, years, etc.

___ BETWEEN

04.

The data type that stores whole numbers

___ CHAR

05.

The command to delete a table or view

___ CHECK

06.

This is used to indicate what table is to be used in a join

___ COMMIT

07.

The command used to change a field’s values

___ COUNT

08.

The function that returns the smallest value in a series

___ CREATE

09.

The command to link attribute values with values in a different table

___ DATE

10.

The command to indicate the owner of the database

___ DECIMAL

11.

A specifier  which extracts non-duplicate values

___ DEFAULT

12.

The command used to build a table or view

___ DISTINCT

13.

The security option that allows users to enter new records

___ DROP

14.

The command to sort the output in some fashion

___ EXISTS

15.

An SQL Program

___ FOREIGN KEY

16.

The data type that allows for small whole numbers

___ GRANT ALL

17.

A virtual table containing selected rows and columns

___ GRANT INSERT

18.

A command that checks if no values have been placed in a field

___ GRANT SELECT

19.

The command which indicates a range of values

___ GRANT UPDATE

20.

A function that returns the no. of items meeting specified requirements

___ INTEGER

21.

The command that checks to see if certain attribute values are present

___ IS NULL

22.

The security option that allows users to edit existing records

___ MAX

23.

This is used to indicate what the unique identifying field is

___ MIN

24

A function that calculates the average value of a series

___ NOT NULL

25.

The conceptual organization of the entire database

___ ORDER BY

26.

The command that indicates that fields should have non-duplicate values

___ PRIMARY KEY

27.

The conceptual organization of a database as seen by the user

___ REFERENCES

28.

The command used to indicate which fields are to be considered

___ ROLLBACK

29.

The command which indicates that a value must be placed in a field

___ Schema

30.

The function that returns the total of value in a range

___ Script

31.

The command to change a table’s properties

___ SELECT

32.

A command which places predefined values in specified fields

___ SET

33.

The command which indicates what table is to be edited

___ SMALLINT

34.

The security option which allows complete access

___ Subschema

35.

The datatype that allows for strings of a variable length

___ SUM

36.

This command is used to negate changes made

___ UNIQUE

37.

The function that returns the largest value in a series

___ UPDATE

38.

The command which makes changes to tables permanent

___ VARCHAR

39.

The security option that allows users to only view the data

___ VIEW

40.

The data type which is used to store real numbers

 

 

      SEE ANSWER

 

The following are short Answer questions are not necessarily intended as having the best solutions, but for instructional purposes. Please note also that some questions and Answers do not necessarily transfer well into HTML Format.

 

1.   List AT LEAST three reasons why SQL is considered the ‘standard’ for databases.

 

      SEE ANSWER

 

2.   List AT LEAST Three different Data Types in SQL, Explain What each is, when to use each, and how each is defined is SQL.

 

      SEE ANSWER

 

3.   Explain What a Schema and a subschema are.

 

      SEE ANSWER

 

4.   List the major components of a schema and explain what each means.

 

      SEE ANSWER

 

5.   We listed 7 basic guidelines for when creating a table (e.g., Choose Numeric data types ONLY if calculations are to be performed on the field

).  List 4 Other ones.

 

      SEE ANSWER

 

6.   Show the CREATE command necessary for the physician Table:

 

      PHYSICIAN(physid, name, address, age)

 

      Where the primary key is physid, name must not be blank, address is the composite key consisting of street, city, state (assume that, by default, all physicians live in Texas (TX)), and zipcode. Assume that no twp physicians can have the same specialty.  Age is the physician’s present age, in whole numbers, as of their last birthday (to avoid the possibility of entry error, let’s assume that a physician must be between the ages of 21 and 90 (Doogie Howser not withstanding)).

 

      SEE ANSWER

 

7.   In conjunction with the above question, add the Patient table:

 

PATIENT(patid, name, address, balance_owed, physid)

 

      Where patid is the primary key. As above, name should be entered. Address is a composite attribute, the same as the physician’s address, and this time, not only can we assume that patients live in Texas, but are all from either Arlington, Dallas or Ft. Worth. Physid is a foreign key that refers to our physician table. The balance_owed can not be negative).

 

      SEE ANSWER

 

8.   We know that patients suffer illnesses. A patient can suffer many illnesses, and an illness can be suffered by many patients. The illness table need only contain the attributes illcode (the primary key) and illname (the name given to the illness, which, again, should not be left blank). Now, of course, we know that a patient CAN have the same illness at two different points in time. Draw the section of the ERD which illustrates this situation and then show the SQL commands necessary to create the tables.

 

      SEE ANSWER

 

9.   Assume that all of the above tables are in place. Dr. J. Kervorkian (physid ‘555443333’, who lives at 203 N. Cooper St., Arlington, TX, 76011, and whose specialty is Surgery (NOTE: THE SAME AS DR. SMITH’S), and who is 45 Years old) is going to take over all of Dr. M. Smith’s (physid ‘123456789’) patients. Her name will then be removed from the physician table. Show all of the necessary SQL commands (be careful of the order of commands issued).

 

      SEE ANSWER

 

10. Let’s assume that when you created the patient table, you only allocated 15 characters to the patient’s name. You now find that you need to allocate 20 characters. Show the SQL necessary to make the change.

 

      SEE ANSWER

 

11. Doogie Howser has appeared. So has a Tibetan Monk, who is also a physician and is 122 years old. You need to change the restrictions on the physician table. A physician’s still must be 16 or greater (State law), but given increases in longevity, can be anywhere up to 200 years old (A soon to be passed State law). Show the commands necessary.

 

      SEE ANSWER


12.    Given the following ERD and corresponding Tables, answer all of the questions that follow:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


                                                                                                                                                                     

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

12.a.  Write the script that would create the tables.

 

            SEE ANSWER

12.b.   Get a list of all the faculty members (listed by department name and professor name), ordered by department.

 

            SEE ANSWER

 

12.c.    Get a list of all of the courses that a department offers (listed by course name and department name), ordered by course name.

 

            SEE ANSWER

 

12.d.               For the above question, unless you added a special command, some courses (notably database) appeared more than once on the list. Correct this situation.

 

            SEE ANSWER

 

12.e.               Get a list of all of the courses that each professor has taught, listed by professor name and course name, ordered by professor name.

 

            SEE ANSWER

 

12.f.   Get a list of classes, list by class ID and enrollment, in decreasing order of class enrollment, where enrollment is greater than 54.

 

            SEE ANSWER

 

12.g.   Get a list of all classes and the department which offered them, listed by department name, professor name, course name, and class name, where enrollment has been greater than 54, ordered by department name, professor name, course name, class ID, and enrollment.

 

            SEE ANSWER

 

12.h.   There are TWO illegal records (NOTE: If there are 2 duplicates, only one of them is illegal). Which are they and why.

 

            SEE ANSWER

 

12.00  Consider the following Situation:

 

Each season, the El Paso Ballet Company puts on a number of ballets. Each ballet has a Ballet_Name (Primary Key), Composer, and Choreographer. Each ballet has many roles. Some roles may appear in many ballets (a common example is that “Girl #1” is a role in many ballets). Each role may be played by any number of Dancers (although a role can only be danced by one dancer at a time). Many dancers may portray many roles, and the same dancer may portray many roles. Because a dancer may dance the same role many times, we need to keep track of the date the dancer portrayed the role. Since there is no rule about two dancers having the same name, dancers are identified by a unique Dancer_Number (Primary key), as well as their names, of course.

 

After much consideration, the DB designer has come up with what appears to be a simple solution. She has determined that a role is simply an associative relationship between a ballet and the individual dancer.

 

To further illustrate the situation, here is some of the data which might be found (across all three tables) for the ballet “Romeo and Juliet”:

 

Ballet_Name

Composer

Choreo-grapher

Dancer_Number

Dancer_Name

RoleName

DanceDate

Romeo & Juliet

Prokofiev

McMillan

1

Nureyev

Romeo

10-Nov-1999

Romeo & Juliet

Prokofiev

McMillan

2

Makarova

Juliet

03-Feb-2002

Romeo & Juliet

Prokofiev

McMillan

3

Farrell

Juliet

10-Nov-1999

Romeo & Juliet

Prokofiev

McMillan

4

Baryshnikov

Romeo

03-Feb-2002

 

a.      Develop the ERD to show this situation.

 

            SEE ANSWER

 

b.      Write the SQL Commands to Create the Tables

 

            SEE ANSWER

 

c.      Populate the tables with the data above

 

            SEE ANSWER

 

d.   Write the SQL Command which would produce the following Output:

 

Dancer                                        Date Danced

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

Makarova                                           10-NOV-99

Farrell                                                      03-FEB-02

 

            SEE ANSWER

 

e.   The DB Designer in the previous program just found out that she had made a bad assumption. She assumed that each ballet had a unique name, single composer, and single composer. As it turns out, a ballet such as “Romeo and Juliet” has two different composers (Prokofiev and Tchaikovsky), and a variety of composers. Some of the different composer/choreography combinations she found were:

 

Composer

Choreographer

Prokofiev

McMillan

Prokofiev

Ashton

Prokofiev

Cranko

Tchaikovsky

Ashton

Tchaikovsky

Lavrovsky

 

Nonetheless, she feels that it is a reasonably easy fix. The concatenated key in table ballet as follows:

 

ballet (ballet_name, composer, choreographer)

 

She feels that this should be sufficient to uniquely identify any ballet. Since these are already fields in the table all she has to do is change the primary key to correspond to this situation.

 

Show how the new ERD would look.

 

            SEE ANSWER

 

f.    Write the commands needed to recreate the tables based on the new ERD (don’t forget to drop the old tables before recreating them).

 

            SEE ANSWER

 

g.   What happens? Why?

 

            SEE ANSWER

 

h.    How could the problem be solved?

 

            SEE ANSWER

 

i.    Rewrite the ERD to reflect this situation

 

            SEE ANSWER

 

j.    Rewrite the table creation commands.

 

            SEE ANSWER

 

13.   Given the following ERD:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


13a.    List the order in which the tables must be created and explain why.

 

            SEE ANSWER

 

13b.    Write the SQL command necessary to create table CLASS.

 

            SEE ANSWER

 

13c.     Get a list of all COURSES (by name) Professor Hernandez (ProfID ‘456789012’) has taught and the semester in which they were taught.

 

            SEE ANSWER

 

13d.    Get a list of all the classIDs (ordered by semester) the Information Systems Department (DeptID ‘INSY’) has offered.

 

            SEE ANSWER

 

13e.    Get a list of students (by name) who have had Professor Johnson (‘Johnson, J.C.’). If a student took more than one class with Professor Johnson, list them only once.

            SEE ANSWER

 

13f.      Get a list of students (by name) who took the course ‘Database Management’ with Professor Chan (‘Chan, C.’) in the Spring, 2001 semester (‘2001, S1 - Spring’).

 

            SEE ANSWER

 

13g.    Get a list of all students (by name) , the name of course they took, who taught it (by Professor Name), and when they took it, who have taken courses from the Management Department (‘Management’) AFTER the Fall, 2000 Semester (‘2000, S3 - Fall’) ordered by the semester in which they took the course.

 

            SEE ANSWER

 

13h.     Get a list of all students, the name of course they took, who taught it, and when they took it, who have taken courses from the Management Department (‘Management’) AFTER the Fall, 2000 Semester (‘2000, S3 - Fall’) ordered by the semester in which they took the course.

 

            SEE ANSWER

 

14.       Given the following ERD, write the necessary SQL commands to answer the questions that follow.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

Additional Notes:

 

1.   Visiting Team and Home Team are foreign keys which refer to the primary key Team_ID in the table Hockey_Team.

2.   HT_Score refers the to Home Team’s Score. VT_Score refers to the visiting team’s score.

3.   StartDate refers to when a player started playing for a team. If a player is still playing with a team, the field EndDate contains the value NULL

 

 

14.0.   Write the SQL Script to create the tables.

 

            SEE ANSWER

 

14.1.   Given the following data, write the commands to insert the data into the tables.

 

Team ID

Team Name

1234

Dallas

2345

Buffalo

3456

Montreal

4567

NY Rangers

5678

Chicago

           

GameID

DatePlayed

HomeTeam

VisitingTeam

HTScore

VTScore

0001

11/10/00

Dallas

Montreal

4

3

0002

11/14/00

NY Rangers

Buffalo

3

5

0003

11/18/00

Chicago

Montreal

2

2

0004

12/05/00

Buffalo

Dallas

5

1

0005

12/12/00

NY Rangers

Montreal

4

0

0006

12/26/00

Dallas

Chicago

5

2

0007

12/30/00

Buffalo

NY Rangers

4

4

0008

01/06/01

Montreal

Chicago

2

1

0009

01/14/01

Chicago

Buffalo

2

6

0010

01/22/01

Montreal

Dallas

0

3

0011

01/24/01

Dallas

NY Rangers

4

2

0012

02/04/01

Dallas

Buffalo

2

6

0013

02/11/01

Chicago

NY Rangers

1

1

0014

02/21/01

Buffalo

Montreal

4

0

0015

03/08/01

NY Rangers

Dallas

2

5

0016

03/14/01

Montreal

Chicago

3

3

0017

04/02/01

Buffalo

Dallas

2

6

0018

04/14/01

Dallas

NY Rangers

1

1

 

 

 

PlayerID

Player Name

Position

Team

Start Date

End Date

98765

Hull, Bret

Center

Dallas

04/15/94

 

87654

Jagr, J.

Wing

Dallas

01/14/99

 

76543

Belfours, E.

Goalie

Dallas

03/12/00

 

65432

Orr, B.

Defense

Dallas

10/01/98

12/04/00

65432

Orr, B.

Defense

Chicago

12/04/00

02/11/01

54321

Borque, R.

Wing

Dallas

04/11/92

 

43210

Bathgate, A.

Wing

Dallas

10/03/89

 

32109

Hasek, D.

Goalie

Buffalo

11/19/94

 

21098

Perot, G.

Center

Buffalo

11/09/84

07/22/97

10987

Martin, R.

Wing

Buffalo

05/30/90

02/11/01

10987

Martin, R.

Wing

Montreal

02/11/01

 

09876

Robert, R.

Wing

Buffalo

03/29/01

 

99887

Horton, T.

Defense

Buffalo

09/25/93

 

88776

Schoenfeld, J.

Defense

Buffalo

05/08/95

 

77665

LaFleur, G.

Wing

Montreal

01/05/97

01/01/01

77665

LaFleur, G.

Wing

NY Rangers

01/01/01

 

66554

Plante, J.

Goalie

Montreal

10/17/84

 

55443

Richard, M.

Center

Montreal

03/22/01

 

44332

LaPointe, G.

Wing

Montreal

12/04/95

 

33221

Robinson, L.

Defense

Montreal

06/12/00

 

22110

Strudland, B.

Wing

Montreal

08/15/93

02/11/01

22110

Strudland, B.

Wing

Buffalo

02/11/01

 

11009

Gretzky, W.

Center

NY Rangers

08/12/91

 

00998

Park, B.

Defense

NY Rangers

02/11/01

 

98876

LeMieux, M.

Wing

NY Rangers

11/16/97

 

87765

Esposito, P.

Wing

NY Rangers

04/01/01

 

76654

Ruutu, C.

Wing

NY Rangers

02/12/90

01/01/01

76654

Ruutu, C.

Wing

Montreal

01/01/01

 

65543

Parent, B.

Goalie

NY Rangers

04/17/88

11/12/00

54432

Esposito, T.

Goalie

Chicago

11/12/00

 

43321

Hull, Bobby

Wing

Chicago

06/14/83

12/04/00

43321

Hull, Bobby

Wing

Dallas

12/04/00

 

32210

Savard, D.

Center

Chicago

09/20/97

 

21109

Howe, G.

Wing

Chicago

11/06/87

 

10098

Lindsey, T.

Defense

Chicago

12/01/00

 

 

 

            SEE ANSWER

 

14.a.   Get a list of the dates (ordered by the date of the game) that Dallas (Team_ID = ‘1234’) played at home.

 

            SEE ANSWER

 

14.b.   Get a list of all of the teams (ordered by team name), and the dates played, that Dallas (TeamID = ‘1234’) played.

 

            SEE ANSWER

 

14.b2.  Get A list of all of the Players (ordered by Player_Name) who have ever played for the Buffalo Sabres (Team Name = ‘Buffalo’)

 

            SEE ANSWER

 

14.c.    Get A list of all of the Players (ordered by Player_Name) who played for the Buffalo Sabres (Team Name = ‘Buffalo’) in the year 2000 AND are still playing for them.

 

            SEE ANSWER

 

14c2.  Get a list (ordered by date played) of all games that ended in a tie.

 

            SEE ANSWER

 

14.d.   Get a list of all of the team names and the dates (ordered by date) that Dallas beat (ONLY) at home.

 

            SEE ANSWER

 

14d2.  Get a list of all players who have played in tie games (ordered by player name). Do NOT duplicate player names.

 

            SEE ANSWER

 

14.e.   Get a list of all the players (ordered by Player_Name), who have played against Dallas in games that Dallas lost ON THE ROAD. Do NOT duplicate player names.

 

            SEE ANSWER

 

14.f.     Get a list of all of the teams (and the date of the game) that beat Dallas in their (the team that played Dallas) own arenas in the year 2000 AND beat them by 3 or more points (ordered by the score they beat them by).

 

            SEE ANSWER

 

14.g.   Get a list of all the players from the Buffalo Sabres (Team Name = ‘Buffalo’) who played against Dallas in winning games at home (in Buffalo) in the months of either January or March of 2001 (Note that both January and March have 31 days: i.e., 01/01/01 to 01/31/01 and 03/01/01 to 03/31/01). Notice also that some players who played with Buffalo might not have been with the Sabres during those times. You will have to check the dates they started and ended).

 

            SEE ANSWER

 

NOTE:   The following questions (although not necessarily difficult) might be beyond the knowledge given in the introductory course). Try Them!!

 

100.    Consider the following ERD:

 

 

** The notation used has been altered to save space

 

102.    In what order must the tables be created?

 

            SEE SOLUTION

 

104.    Show the SQL commands necessary to create table Building. Show all Primary and Foreign Keys. Assume that no two buildings can have the same name, and must be included in the record. Also assume that most of the most of the classes are held in the ‘Classroom Building’.

 

            SEE SOLUTION

 

105.    Enter the following data into table Building:

 

BuildID

BuildName

10

COBA

11

UGLC

12

Classroom Building

 

            SEE SOLUTION

 

 

107.    Show the SQL commands necessary to create table Classrooms. Show all Primary and Foreign Keys. Assume that no fields can be left empty. Make sure capacity is greater than zero (0).

 

            SEE SOLUTION

 

108.     Ah!! What a moron!! I forgot to tell you to make sure that two (or more) room numbers are assigned to the same building. Add the constraint (without dropping the table) to do this.

 

            SEE SOLUTION

 

109.     Enter the following data into table Classrooms

 

Classroom

Building

RoomNum

Capacity

1

10

301

40

2

10

302

35

3

10

303

35

4

10

321

20

5

10

320

30

6

11

306

50

7

11

307

45

8

11

308

30

 

 

            SEE SOLUTION

 

112.    Show the SQL commands necessary to create table Semester. Show all Primary and Foreign Keys. Remember that this is simply unique information about a semester. Each semester should have a unique name (e.g., Fall 2003), and unique starting and ending times (e.g., two semesters can not start on, September 1, 2004 – or can they? Maybe, buts let’s assume they can’t – for now) and of course we need to protect against dumb entries (e.g., a semester can not end before it begins).

 

            SEE SOLUTION

 

114.    Enter the following data into table Semester

 

SemID

Semname

Semstart

Semend

100

Fall 2002

Aug 28 2002

Dec 05 2002

102

Spring 2003

Jan 12 2003

May 05 2003

103

Summer I 2003

May 15 2003

June 25 2003

 

            SEE SOLUTION

 

116.    The way we laid things out has caused us a few problems. Remember the relationship between department and Instructor?

 

 

Which one gets created first?

 

The answer is Either one, BUT we can’t add the foreign key (for at least one of them) until they are both created. Here’s how we can do it:

 

1.      Create Table Department (without the foreign key reference)

2.      Create Table Instructor (with the foreign key reference)

3.      Alter table Department by adding the foreign key reference

 

Just a few additional considerations:

 

q             Table Department should not accept any null values, and department name should be unique

q             Table Instructor should also not accept any null values

 

            SEE SOLUTION

 

118.    Enter the following data into table Department

 

DeptID

DeptName

DeptChair

100

IDS

345678901

101

Accounting

567890123

102

Finance

678901234

 

            SEE SOLUTION

 

120.    Enter the following data into table Instructor

 

InstID

InstName

Dept

123456789

Kirs

100

234567890

Joseph

100

345678901

Udo

100

456789012

Bagchi

100

567890123

Eason

101

678901234

Braun

102

 

            SEE SOLUTION

 

122.    Create tabe Course. There should be no null values allowed and Course Name shoule be unique.

 

            SEE SOLUTION

 

124.    Enter the following data into table Course

 

CourseID

CourseName

Depart

100

Database

100

101

Data Structures

100

102

Systems Analysis

100

103

Data Comm.

100

104

C++

100

105

Accounting

101

 

            SEE SOLUTION

 

126     Create table Course. The constraints need a little explanation:

 

q             Classes can only meet on certain days:

o             MWF, MW and TR

q             Depending on what day they meet, the starting times are different:

o             MWF classes can start at 7:30 AM, 8:30 AM, 9:30 AM, 10:30 AM and 11:30 AM

o             MW classes can start at 6:00 PM and 7:30 PM

o             TR classes can start at 7:30 AM, 9:00 AM, 10:30 AM, 12:00 PM, 6:00 PM and 7:3- PM

q             The cap must be greater than zero (0)

q             No two classes can be scheduled in the same room at the same time

q             An instructor can not teach two classes at the same time

 

 Write the SQL Commands needed

 

            SEE SOLUTION

 

128.    Enter the following data into table Class

 

 

ClassID

CourseID

InstID

Semester

Days

Times

Room

Cap

5000

100

123456789

100

MWF

8:30 AM

1

40

5001

102

345678901

100

TR

10:30 AM

2

50

5002

100

123456789

100

TR

1:30 PM

1

30

5003

101

123456789

100

TR

6:00 PM

3

35

5004

100

123456789

102

MW

6:00 PM

2

25

5005

102

456789012

102

TR

10:30 AM

4

40

5006

103

234567890

102

TR

1:30 PM

5

50

 

            SEE SOLUTION

 

130.    Create table Major. Very simple: No null values, unique Major Name

 

            SEE SOLUTION

 

132.    Enter the following data into table Major

 

Major ID

MajorName

Dept

100

CIS

100

101

POM

100

102

Accounting

101

 

            SEE SOLUTION

 

134.    Create table Student. Also very simple: Major can be undeclared

 

            SEE SOLUTION

 

136.    Enter the following data into table Student

 

 

StudentID

StudentName

Major

987654321

Simpson, Homer

100

876543210

Cheney, Dick

101

765432109

Lopez, Jennifer

100

654321098

Williams, Venus

100

543210987

De La Hoya, Oscar

102

432109876

Bush, Georgina

101

321098765

Seinfeld, Jerry

NULL

210987654

Ming, Yao

100

109876543

Abul-Jabar, Kareem

102

098765432

Enem, Em

100

001122334

De Lion, Dan

100

112233445

Kafka, Franz

101

667788990

Galt, John

102

223344556

Powell, Colin

102

334455667

Fox, Vincente

100

445566778

Berry, Hallie

101

556677889

Toledo, Alejandro

100

 

            SEE SOLUTION

 

138.    Create table Enrollment. Some considerations:

 

q             Grades can be NULL, A, B, C, D, F, I, W

q             A student can not be enrolled in the same class twice

 

            SEE SOLUTION

 

140.    I have inserted 48 records into table Enrollment. I won’t ask you to enter them. To see the entries, click HERE. To download a Zipped ASCII File of ALL the data inserted (for all the tables), click HERE.

 

170.    Suppose that we wanted to drop all of the tables. In what order must we do it (CAUTION: REMEMBER THAT DEPARTMENT AND INSTRUCTOR BOTH REFER TO EACH OTHER)

 

SEE SOLUTION

 

174.    Get a list of all instructors (by name) and the department (by name) that they belong to ordered by department and within department, by instructor name) (NOTE: We know there are only six Instructors)

 

SEE SOLUTION

 

178.    Get a list of all Buildings and the classrooms in them (and their capacities) that have a capacity of 40 or more, listed alphabetically by building (NOTE: There are three)

 

SEE SOLUTION

 

182.    Get a list of all the unique courses that each instructor has taught (listed by instructor and course name) (NOTE: There should be 5 lines of output)

 

SEE SOLUTION

 

186.    Get a list of all the courses (as “Course Name”, not coursename) that the IDS department offered in “Spring 2003”  (NOTE: There should be three)

 

SEE SOLUTION

 

190.    How many students have been in each of the classes offered?  (NOTE: We know that there have only been 7 classes)

 

SEE SOLUTION

 

194.    Get a list of all CIS majors (by name, alphabetically) who took ‘Database’ in ‘Spring 2003’ with ‘Kirs’.  (NOTE: There are 4)

 

SEE SOLUTION

 

198.    How many of these student received an ‘A’?  (NOTE: There was only one)

 

SEE SOLUTION

 

202.    Get a list of all of the courses offered (by name), the department that offered it (by DeptName) the semester they were offered (by SemName), who taught it (by InstName), where it was offered (by BuildName and RoomNumber), what the room capacity was, and what the department Cap was (while you’re at it, clean up the labels a bit)  (Remember, there were only seven classes offered)

 

SEE SOLUTION

 

206.    Write a VIEW to link all the tables together (so we won’t have to go through this again)

 

SEE SOLUTION

 

210.    Use your view get a list of all ‘CIS’ majors (alphabetically)

 

SEE SOLUTION

 

214.    Use your view get a list get a class transcript for  ‘Simpson, Homer’

 

SEE SOLUTION

 

218.    Use your view get a list get a list of all classes (by coursename) that have been taught in ‘COBA’ room ‘301’, when they were taught (by semester name) and who the instructor was for the course

 

SEE SOLUTION