Describe the circumstances in which you would choose to use embedded SQL rather than SQL alone or only a general-purpose programming language.

 

5.1 Describe the circumstances in which you would choose to use embedded SQL rather than SQL alone or only a general-purpose programming language.

Answer:

5.2 Write a Java function using JDBC metadata features that takes aResultSet as an input parameter, and prints out the result in tabular form, with appropriate names as column headings.

Answer:

 

5.3 Write a Java function using JDBC metadata features that prints a list of all relations in the database, displaying for each relation the names and types of its attributes.

Answer:

5.4 Show how to enforce the constraint “an instructor cannot teach in two different classrooms in a semester in the same time slot.” using a trigger (remember that the constraint can be violated by changes to the teachesrelation as well as to the section relation).

Answer:

5.5 Write triggers to enforce the referential integrity constraint from sectiontotimeslot, on updates to section, and time

in Figure 5.8 do not cover the update operation.slot. Note that the ones we wrote 5.6 To maintain the tot cred attribute of the studentrelation, carry out the fol-lowing:

a. Modify the trigger on updates of takes, to handle all updates that canaffect the value of tot

b. Write a trigger to handle inserts to the takes relation.cred.

c. Under what assumptions is it reasonable not to create triggers on thecourse relation?