Assignment 2

Due date: Monday, September 30, 11:59PM.
NOTES:
This assignment is meant to give you practice with the SQL DDL.

Student Equipment Loans

The students at the University Moon Light are offered the ability to loan electronic equipment for class work, such as Tablets, Laptops, monitors, projectors, etc. Below is the schema used by the loan center to record the student loans.
Database EquipmentLoans
Students(SID, FNama, LName, Dept_Name, Email)
Equipment(EID, TCode, TypeID, Location)
TypeID is FK references EquipmentTypes
Loans(SID, EID, CheckOutDate, CheckOutTime, CheckInTime, CheckedOutBySID)
SID is FK references Students
EID is FK references Equipment
CheckedOutBySID is FK references Students
EquipmentTypes(TypeID, Name, Description, LoanRateHour)

Tasks

  1. Create Database
    1. Write SQL DDL statements to create the database along with all its tables.
    2. You need to pick the appropriate attribute data type for each attribute.
    3. The statements must include all integrity constraints.
  2. Alter Database
    1. Modify the data type of LoanRateHour to be NUMERIC (4, 2).
    2. Rename the field CheckedOutBySID to StudentOnDuty.
    3. Introduce ON DELETE CASCADE on CheckedOutBySID.
    4. Make (FNama, LName, Dept_Name) a Unique Key in Stundets.
    5. Introduce the constraint that CheckOutTime < CheckInTime.
    6. Introduce the constraint that SID <> CheckedOutBySID.
    7. Rename the table Loans to StundetLoans.
    8. Use Insert statement to:
      1. Insert at least 10 students
      2. Insert at least 10 records in Equipment.
      3. Insert at least 20 loans
      4. Insert at 5 types of equipment.
  3. Delete Database
    1. Delete the content of all tables.
    2. Delete the tables themselves.

Deliverables

  1. You have to produce a SQL script that accomplishes all the above steps. For each of the above items, there must be a corresponding set of statements in your script. Introduce comments in your script to indicate which item your SQL statements address.
  2. A document containing Picture Screens captures from your computer showing the successful execution of each item in A), followed by those in B) followed by those in C).