DB-Library-System-Project
DB-Library-System-Project
College of Commerce
Information Technology Department
2nd Stage – 1st Semester
Submitted By
Aram Rafiq
Rawezh Rostam
Linda Zana
Supervised by
Mr. Bilal Najmaddin Rashid
2024
Table of Contents
Table
s
1. Conceptual Design:.........................................................................2
1.1 Diagram:...........................................................................................................................2
2. The Books Table:............................................................................3
2.1 Inserting Values:...............................................................................................................3
2.2 Updating Values:...............................................................................................................3
2.3 Inserting a Null Value into Title Column:........................................................................4
3. Member Table:................................................................................4
3.1 ALTER Operations:..........................................................................................................4
3.2 Data Insertion:..................................................................................................................5
3.3 Data Manipulation:...........................................................................................................6
3.4 Violating Constraints:.......................................................................................................7
4. Borrowing Table:............................................................................8
4.1 ALTER Operation:............................................................................................................9
4.2 INSERT Operation:..........................................................................................................9
4.3 Data Manipulation:.........................................................................................................10
4.4 Violating Constraints:....................................................................................................11
5. Bonus:............................................................................................12
5.1 Librarians table:..............................................................................................................12
5.2 ALTER Operations:........................................................................................................12
5.3 TURNCATE Operate:.....................................................................................................12
1
1. Conceptual Design:
In this diagram we create a relation between the books and borrowing table and between
members and borrowing table:
1. Books and borrowing: Each book can be borrowed multiple times, and each borrowing
refers to one book. (One-to-Many).
2. Members and borrowing: each member can do several borrowings, and each borrowing
only refers to a specific member. (One-to-Many).
1.1 Diagram:
BorrowDate MemberID
BorrowID
BookID
FirstName
Price
Borrowing LastName
Title Books Members
Genre Gender
BookID
DateOfBirth
FK ReturnDate
Address
MemberID
FK
2
2. The Books Table:
3
2.3 Inserting a Null Value into Title Column:
(Aram Rafiq)
3. Member Table:
Creating a members table:
Increasing Address Column with DEFAULT constraints, by default the members are from
Sulaimani city but if any member are not from there, the user can enter another city in the
Address field.
4
2- Using ALTER table to rename the PhoneNumber Column to ContactNumber:
3- Using ALTER table to change the data type of the ContactNumber column to
VARCHAR(20):
4-
Using ALTER table to add a NOT NULL constraints to the ContactNumber column:
5- Using ALTER table to delete the ContactNumber column from members table:
5
3.2 Data Insertion:
We can see, the address by default is Sulaimani, if the user does not insert any other Address.
3.3 Data
Manipulation:
1- Updating
one of the
user’s email:
6
3- Select any members where their birth date is greater than (2005-1-1)
The result:
The result:
7
2- Insert multiple choice of enum constraints:
(Rawezh Rostam)
4. Borrowing Table:
Our third table is borrowing table which manages the borrowings of the books and when they
should be returned, this is how we code it:
8
Now I want to add another column for the table named “ExtendedDate” which is used for
extending the borrowing date for example if someone wanted to keep the book for a little
longer, they need to extend their return date.
By doing this we added a new column, and the structure will become like this:
VALUES(‘data’);
9
4.3 Data Manipulation:
Now let’s say we want to update a borrowing record’s ReturnDate we have to make sure it
checks the CHECK constraint.
Now if a data deletes in the other tables, the related data in this table will get deleted too.
As you can see one of the rows got deleted because one of the members who borrowed a
book got deleted from the table.
10
4.4 Violating Constraints:
If we want to insert a borrowing record where ReturnDate is earlier than the BorrowDate we
will get an error, because we gave it a check (CHECK(RturnDate>BorrowDate)).
(Linda Zana)
11
5. Bonus:
5.1 Librarians table:
Creating Librarians table:
12
We cannot , and the error message:
Instead
of
using
TRUNCATE , we use DELETE operate to delete all the data of the tables:
13