Homework 1 (due 4/4)
CSC 453


We talked about database management systems in general, establishing some basic terminology and background (Chapter 1). We continued with the relational data model (Sections 2.1, 2.2, 2.5) and covered most of SQL DDL (Section 2.3).

We also saw Oracle SQL Developer, our interface to an Oracle SQL Database Server. I have emailed out a list of instructions on how to set-up Oracle SQL Developer on your machine, and you can also find those instruction (together with database files and presentation files) on d2l.

Next week we will complete SQL DDL, and start on Chapter 6 on SQL (DML).

 On the dangers of entity integrity constraints in real life, see the NO TAGS article.



Handing it in: Submit to the d2l dropbox. Use some standard format for your homework (Word or pdf, for example), and make sure to include your name and assignment number (if you are on a Mac, please don't use the .pages format, convert to pdf). Include screenshots for code and testruns. You do not need to include the code (or any executables). Please include all material in a single file (and don't use zip). See SampleHWSubmission.docx (or SampleHWSubmission.pdf) for a sample.

1. (Reading Assignment) Read Chapter 1 (with emphasis on Section 1.2), and Chapter 2 (skipping Section 2.4) of the textbook (Garcia-Molina, Ullman, Widom, Database Systems. The Complete Book).

2. (Relational Schema, 15pt). Create a set of relational schemas with domains, underlined primary keys and arrows pointing from foreign keys to the primary key they refer to for a database containing the following information:

For the following problems you need the university.sql script (on d2l), and access to our SQL database, instructions also on d2l.

3. (University Database, 15pt). For this problem you will modify the DDL code that creates the university database so it supports the following features:

  1. Space on transcripts is limited, so there are only 20 characters for each course name. Add a field short_title that allows you to store an alternative short name for each course. (E.g. 'Theory of Comp' for 'Theory of Computation').

  2. Our university sometimes cross-lists courses (e.g. the graduate CSC 489 may be cross-listed with the undergraduate CSC 389). We allow at most one cross-list per course.

  3. Every course has a cap on the enrollment. By default this value should be 40. In general, the number is allowed to be at most 50 (for the CHECK constraint you can <, <=, etc.).

  4. A student can select a grading basis when enrolling in a class; there are three choices: PF(pass/fail), CR (student receives a letter grade), and AU (audit, no grade assigned). Add a field to the database which supports storing this information. Default is CR. This field may not be null, that is, a grade basis must be selected, and the selected grade basis must be one of the three values PF, CR, or AU.

Modify university.sql so it can deal with this information. This will require updating the DDL (CREATE TABLE command). Don't worry about modifying the INSERT commands, but see what happens (in particular, check that the default values are set correctly).

For submission: Only submit the relevant parts (i.e. the new CREATE TABLE commands), and some data from the affected tables to show that the fields were created (and, were appropriate, the default values were set).

Hint:  Read through the current university.sql first to get familiar with the syntax. For c and d remember that in Oracle the default value must come before the check constraint.

 4. (Constraints, 10pt) According to Codd's Twelve Rules everything in a datbase is stored in tables. Including constraints. Let's check out the system table sys.all_constraints. Use a simple

SELECT * FROM sys.all_constraints;

to get the contents of that table. To look for a specific table, say STUDENT, look for table_name = 'STUDENT' (in the SELECT query to can restrict by saying SELECT * FROM sys.all_constraints WHERE table_name = 'STUDENT').

a) Can you make sense of the records for the STUDENT table?

b) Can you identify the records resulting from the work you did for 3c and 3d above (not in the student table)?

Include a screenshot of relevant records with a short explanation.


Marcus Schaefer
Last updated: March 30th, 2018.