Documente Academic
Documente Profesional
Documente Cultură
Assignment Part 1
Due date: A draft (hard copy) on Tuesday-Week4 in class
Final soft-copy on Friday-Week5 5 pm via LearnJCU
Data Type
Positive whole number
Variable length string
author_lname
Table 2: Book_Author
Column
Data Type
book_author_id
Positive whole number
author_id
Positive whole number
Comments
Primary key
Max of 50 characters; null not allowed; (author_fname, author_lname)
is unique
Max of 50 characters; null not allowed
book_id
Comments
Primary key
Foreign key to the table Author; (author_id, book_id) is unique; null not
allowed
Foreign key to the table Book; null not allowed
Table 3: Publisher
Column
publisher_id
publisher_name
publisher_url
publisher_email
Data Type
Positive whole number
Variable length string
Variable length string
Variable length string
Comments
Primary key
Max of 50 characters; null not allowed
Max of 100 characters; null allowed; unique
Max of 50 characters; null allowed; unique
Comments
Primary key
2 characters; null not allowed; book category must belong to one of the
following items:
BU (business)
LA (law)
AC (accounting)
IT (info tech)
TO (tourism)
HO (hospitality)
HU (human resource)
UN (unclassified or general)
Table 5: Book
Column
book_id
isbn
publisher_id
title
cat_id
Data Type
Positive whole number
Variable length string
Positive whole number
Variable length string
Positive whole number
shelf_letter
call_number
no_of_pages
no_of_copies
date_arrived
Table 6: Copies
Column
copy_id
book_id
copy_number
Data Type
Positive whole number
Positive whole number
Positive whole number
Comments
Primary key
Foreign key to the table Book; null not allowed
null not allowed; (book_id, copy_number) is unique; copy_number is
between 1 and no_of_copies (Book) -- you do not need to implement
this condition, it will be done by a trigger in Assignment - Part2
Table 7: Subject
Column
subject_id
subject_name
subject_code
Data Type
Positive whole number
Variable length string
Variable length string
Comments
Primary key
Max of 50 characters; null not allowed
Max of 15 characters; null not allowed; unique
Table 8: Book_Subject
Column
Data Type
book_subject_id
Positive whole number
book_id
Positive whole number
subject_id
Positive whole number
Comments
Primary key
Max of 20 characters; null not allowed; unique
Foreign key to the table Publisher; null not allowed
Max of 100 characters; null not allowed
Foreign key to the table Cat; null not allowed; (shelf_letter,
call_number) is unique
1 character from A to Z; null not allowed
From 1 to 999
null allowed
must be >= 1; null not allowed
Default should be the current date and time (use a function to generate
the default value); null not allowed
Comments
Primary key
Foreign key to the table Book; null allowed
Foreign key to the table Subject; null not allowed; (book_id, subject_id)
is unique
2
subject_ref
Table 9: Loan
Column
loan_id
borrower_id
copy_id
date_out
Data Type
Positive whole number
Positive whole number
Positive whole number
Date/Time
date_due
Date/Time
date_returned
Date/Time
Comments
Primary key
Foreign key to the table Borrower; null not allowed
Foreign key to the table Copies; null not allowed
Default should be the current date and time (use a function to generate
the default value);
null not allowed;
When data is filled it should be <= current date -- you do not need to
implement this condition, it will be done by a trigger in Assignment Part2 (noted that sysdate function cannot be used in check constraint)
Default should be one week from the current date and time (use a
function to generate the default value); null not allowed
When data is filled it should be checked if date_due is 7 days more than
date_out
null allowed;
When data is filled it should be >= date_out;
When data is filled it should be <= current date -- you do not need to
implement this condition, it will be done by a trigger in Assignment Part2
Data Type
Positive whole number
Variable length string
borrower_lname
borrower_email
borrower_phone
borrower_street
borrower_suburb
borrower_postcode
borrower_type
date_registered
exc_key_value
exc_date
Comments
Primary key
Max of 50 characters; null not allowed; (borrower_fname,
borrower_lname) is unique
Max of 50 characters; null not allowed
Max of 50 characters; null not allowed; unique; contains an @ (Bonus:
if being able to set x@x.x)
Max of 20 characters; null allowed
Max of 50 characters; null not allowed
Max of 50 characters; null not allowed
four numerical digits; from 0200 to 9999; null not allowed
1 character: S(student) or L(lecturer) or O(other) ; null not allowed;
Default should be the current date and time (use a function to
generate the default value); null not allowed
Comments
Primary key
Trigger name in which the exception occurred
Max of 30 characters null not allowed
Name of the table containing the exception
Max of 30 characters null not allowed
Primary key value of the row with the exception
The date and time when the exception occurred; Default should be the
current date and time (use a function to generate the default value);
null not allowed.
exc_text
Hint: Add a new model: File New Model; double-click on Add Diagram; click
or press T and then click
on the Diagram editor to add a new table; double-click on the new-added table to edit: you can now change
the table name, define columns and foreign keys; when completed you can export the diagram: File Export
Export as PNG.
b) Good database design is to achieve the third normal form (3NF) of the database. Is LIBDB at the 3NF? If not,
how can you re-design it to achieve 3NF?
Note: You can find information about normalization at http://support.microsoft.com/kb/283878 or any other
relevant resources.
Task4 submission file:
Produce a word file as A1Task4.docx including your answers on a and b.
SUBMISSION ON LEARNJCU
Submission date: By 5 pm Friday Week 5 22/08/2014.
Submit your final copy as a zip file named jcnumber.zip (e.g. jc123456.zip) containing A1Task1.sql,
A1Task2.sql, A1Task3 and A1Task4.docx on LearnJCU. You can find the submission link inside the Assignments
folder which is located inside the Subject Materials folder.