You are on page 1of 5

1 | Page

Section-1
Project Description
Book Store Information System
This system is about the information of an individual book store. The system
has basically three tables ( Employee, Books, BookSales). All the information of
books is stored in Books table. Employee table has all the information of employee
and BookSales table contains book sales information. The system has three general
users: Manager, Marketing_Manager and Salesperson. Manager has all privileges
on all tables. Marketing_Manager has all privileges on Books and retrieve
privilege on BookSales table and order books of those quantities less than or equal
to 5. Salesperson has retrieve and insert privileges on BookSales Table. Book sales
log are done by creating triggers and also for the changed prices of the books.

2 | Page

Section 2
Database Design
Employee
Emp_id
Emp_name
Emp_dob
Emp_address
Emp_phno
Position
Salary

Char(6)
Char(20)
Date
Char(50)
Int
Char(20)
Decimal

PK

Not Null

Char(5)
Char(30)
Char(30)
Int
Char(20)
Decimal
Int

PK

Not Null

Char(5)
Char(6)
Int
Decimal

FK
FK

Not Null
Not Null

Books
Book_id
Book_name
Author
Pub_Yr
Category
Price
Qty
BookSales
Book_id
Emp_id
SalesQty
TotalPrice

3 | Page

Section 3
Integrity Constraints
1. Every primary key and foreign keys pairs are integrity constraints for this
system.
2. Emp_id has to be like first three characters would have to be EMP, and then
followed by integers ranging from 1 to 999.
Type Emp_id POSSREP (Char) Constraint
Substr( The_Emp_id (Emp_id),1,3) = EMP and
Cast_As_Integer (Substr (The_Emp_id (Emp_id),4) > 0) and
Cast_As_Integer (Substr (The_Emp_id (Emp_id),4) 999);
3. Book_id has to be like first character would have to be B, and then followed
by integers ranging from 1 to 9999.
Type Book_id POSSREP (Char) Constraint
Substr( The_Book_id (Book_id),1,1) = B and
Cast_As_Integer (Substr (The_Book_id (Book_id),2) > 0) and
Cast_As_Integer (Substr (The_Book_id (Book_id),2) 9999);
4. Only legal values for Category field are: Humor, Thriller, Romance, Science
Fiction, Arts, Business, Children, Computers & Technology, Cooking, Health,
History, Politics, Sports, Travel.
Type Category POSSREP (Char) Constraint
The_Category (Category) = Humor OR
The_Category (Category) = Thriller OR
The_Category (Category) = Romance OR
The_Category (Category) = Science Fiction OR
The_Category (Category) = Arts OR
The_Category (Category) = Business OR
The_Category (Category) = Children OR
The_Category (Category) = Computers & Technology OR
The_Category (Category) = History OR
The_Category (Category) = Politics OR
The_Category (Category) = Sports OR
The_Category (Category) = Travel;
5. The Salesperson has to check that the book quantity that has to be sold must
be less than or equal to available quantity.
Section 4
Security Constraints

4 | Page

1. Create user Manger identified by admin;


2. Create user Marketing_Manager indentified by market;
3. Create user Salesperson identified by sales;
User Manager has all privileges on all tables.
1. Grant All
On Books
To Manager;
2. Grant All
On Employee
To Manager;
3. Grant All
On BookSales
To Manager;
User Marketing_Manager has all privileges on Books, retrieve privilege on
BookSales table.
1. Grant All
On Books
To Marketing_Manager;
2. Grant Retrieve
On BookSales
To Marketing_Manager;
User Salesperson has retrieve and insert privileges on BookSales Table.
1. Grant Retrieve, Insert
On BookSales
To Salesperson;

Section 5
Trigger Procedure
Recording of book sales log can be done by a trigger.

5 | Page

Create Table BookSales_Log (B_id char(5), qty int, SalesTime Timestamp);


Delimiter //
Create Trigger BookSalesTime_Trigger
After Insert Into BookSales For Each Row
Begin
Insert Into BookSales_Log Values(New.Book_id, New.Sales_Qty,
Now());
End;
Delimiter;

Recording of changing price of the books can also be done by a trigger.


Create Table BookPrice_Log(B_id char(5), old_price int, new_price int,
UpdatedTime Timestamp);
Delimiter //
Create Trigger BookPrice_Trigger
Before Update On Books For Each Row
Begin
Insert Into BookPrice_Log(Old.Book_id, Old.Price, New.Price,
Now());
End;
Delimiter;

You might also like