0% found this document useful (0 votes)
112 views

Creation of Database Using Derby DB. Our Derby Bookstore Database Contains Tables: Authors (Authorid, Firstname, Lastname, EMAIL) 4 Attributes

The document describes the creation of a bookshop database and GUI system. It details the tables created in the database to store information about authors, books, customers, orders and more. It also outlines the graphical user interface created for staff to register customers, process orders, and for administrators to manage operations like adding authors and books.

Uploaded by

Avinash Dilip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views

Creation of Database Using Derby DB. Our Derby Bookstore Database Contains Tables: Authors (Authorid, Firstname, Lastname, EMAIL) 4 Attributes

The document describes the creation of a bookshop database and GUI system. It details the tables created in the database to store information about authors, books, customers, orders and more. It also outlines the graphical user interface created for staff to register customers, process orders, and for administrators to manage operations like adding authors and books.

Uploaded by

Avinash Dilip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Project: Bookshop System

----**Bookshop_Lab1**----
1. Creation of database using derby DB.
Our derby bookstore database contains tables:
AUTHORS (AUTHORID, FIRSTNAME, LASTNAME,
EMAIL) 4 attributes
AUTHORID: Author’s ID number in the database.
In the bookstore database, this integer column is defined as auto-
incremented, that is for each row inserted in this table the AUTHORID
value is increased by 1 automatically to ensure that each row has a unique
AUTHORID.
This column represents the table’s primary key.
[Note: The author’s NIC could also have been used as the primary key]
Auto-incremented columns are so-called identity columns.
Our SQL script for this database uses the SQL IDENTITY keyword to
mark the AUTHORID column as an identity column.
FIRSTNAME: first name of the author, a string value
LASTNAME: last name of the author, a string value
EMAIL: email of the author, a string value

BOOKS (BOOKISBN, TITLE, EDITIONNUMBER,


COPYRIGHT, QUANTITY, PRICE) 6 attributes
BOOKISBN: ISBN of the book (a string).
The table’s primary key (but does not auto-increment).
ISBN is an abbreviation for “International Standard Book Number”- a
numbering scheme that publishers use to give every book a unique
identification number.

1
TITLE: Name of the book, a string value.
EDITIONNUMBER: Edition number of the book, one integer value.
COPYRIGHT: Year book was published, of type DATE.
QUANTITY: Number available in stock, type integer.
PRICE: Cost of one copy of the book, type double.

BOOKAUTHOR ( , )2
attributes
The BOOKAUTHOR table consists of two columns that maintain ISBNs
for each book and their corresponding authors’ ID numbers.
This table associates authors with their books.
The AUTHORID column is a foreign key—a column in this table that
matches the primary-key column in another table (that is, AUTHORID in
the AUTHOR table).
The BOOKISBN column is also a foreign key—it matches the primary
key column (that is, BOOKISBN) in the BOOKS table.
A database might consist of many tables.
Always remember that your goal when designing a database is to minimize
the amount of duplicated data among the database’s tables.
Foreign keys, which are specified when a database table is created in the
database, link the data to multiple tables.
Together the AUTHORID and BOOKISBN columns in this table form a
composite primary key.
Every row in this table uniquely matches one author to one book ISBN.

CUSTOMERS (CUSTNIC, FIRSTNAME, LASTNAME,


STREETADDRESS, PHONE, EMAIL,
DATEOFBIRTH, CITY, POSTALCODE, IMAGE) 10
attributes

2
DOCUMENTS (DOCUMENTID, COMMENTS,
PATH) 2 attributes

ORDERS (ORDERID, , ,
DATECREATED, PAYMENTAMOUNT,
QUANTITYPURCHASED) 6 attributes

SUPPLIERS ( , FIRSTNAME,
LASTNAME, STREETADDRESS, PHONE, EMAIL,
CITY, POSTALCODE, COMPANYNAME) 9
attributes

BOOKSUPPLIER ( , )2
attributes

SUPPLIERORDERS (ORDERID, ,
DATECREATED, QUANTITYORDERED,
TOTALAMOUNT) 5 attributes

3
EMPLOYEE (EMPNIC, EMPFIRSTNAME,
EMPLASTNAME, STREETADDRESS, CITY,
POSTALCODE, PHONE, EMAIL, DATEOFBIRTH,
PROFILEIMAGE, USERNAME, PASSWORD,
USERLEVEL) 13 attributes

Every foreign-key value must appear as another table’s primary-key value


so the DBMS can ensure that the foreign key value is valid, this is known
as the Rule of Referential Integrity.

For example, our Bookstore DBMS ensures that the AUTHORID value
for a particular row of the AUTHORISBN table is valid by checking that
there is a row in the AUTHORS table with that AUTHORID as the
primary key.

Foreign keys also allow related data in multiple tables to be selected from
those tables, this is known as joining the data.

There is a one-to-many relationship between a primary key and a


corresponding foreign key (for example, one author can write many books
and one book can be written by many authors).

This means that a foreign key can appear many times in its own table but
only once (as the primary key) in another table.

For example, the BOOKISBN 0132151006 can appear in several rows of


AUTHORISBN (because this book has several authors) but only once in
BOOKS, where BOOKISBN is the primary key.

4
Every row must have a primary-key value, and that value must be
unique in the table.

This is known as the Rule of Entity Integrity.

Again, for the AUTHORISBN table, the primary key is the combination
of both columns, this is known as a composite primary key.

5
CREATE TABLE "AUTHORS" (
"AUTHORID" INT NOT NULL GENERATED
ALWAYS AS IDENTITY,
"FIRSTNAME" varchar (20) NOT NULL,
"LASTNAME" varchar (30) NOT NULL,
"EMAIL" varchar (50) NOT NULL,
PRIMARY KEY ("AUTHORID")
);

CREATE TABLE "BOOKS" (


"BOOKISBN" varchar (20) NOT NULL,
"TITLE" varchar (100) NOT NULL,
"EDITIONNUMBER" INT NOT NULL,
"COPYRIGHT" DATE NOT NULL,
“QUANTITY” INT NOT NULL,
“PRICE” DOUBLE NOT NULL,
PRIMARY KEY ("BOOKISBN")
);

6
CREATE TABLE "BOOKAUTHOR" (
"AUTHORID" INT NOT NULL,
"BOOKISBN" varchar (20) NOT NULL,
FOREIGN KEY ("AUTHORID") REFERENCES
"AUTHORS" ("AUTHORID"),
FOREIGN KEY ("BOOKISBN") REFERENCES
"BOOKS" ("BOOKISBN")
);

INSERT INTO "AUTHORS" ("FIRSTNAME",


"LASTNAME","EMAIL")
VALUES
('Harvey','Deitel','[email protected]'),
('Paul','Deitel','[email protected]'),
('Andrew','Goldberg','[email protected]'),
('David','Choffnes','[email protected]');

7
INSERT INTO "BOOKS"
("BOOKISBN","TITLE","EDITIONNUMBER","COPY
RIGHT", “QUANTITY”,”PRICE”)
VALUES
('0131869000','Visual Basic 2005 How to
Program', 3, '2006-03-12', 2, 1250.5),
('0131525239','Visual C# 2005 How to
Program', 2,'2006-08-21',3,1500.0),
('0132222205','Java How to Program',7,'2007-
11-10',5,1800),
('0131857576','C++ How to Program',5,'2005-
01-30',3,1005.25),
('0132404168','C How to Program',5, '2007-02-
28',8,850.25),
('0131450913','Internet & World Wide Web
How to Program',3,'2004-12-12',7,1505.5),
('0131452715','Epidemiology',1,'2020-01-
20',20,450.55),
('0131828274','Operating Systems',3,'2004-05-
18',5,1985.25);

8
INSERT INTO "BOOKAUTHOR"
("AUTHORID","BOOKISBN") VALUES
(1,'0131869000'),
(2,'0131869000'),
(1,'0131525239'),
(2,'0131525239'),
(1,'0132222205'),
(2,'0132222205'),
(1,'0131857576'),
(2,'0131857576'),
(1,'0132404168'),
(2,'0132404168'),
(1,'0131450913'),
(2,'0131450913'),
(3,'0131450913'),
(1,'0131828274'),
(2,'0131828274'),(4,'0131828274');

9
CREATE TABLE "EMPLOYEE" (
"EMPNIC" varchar (14) NOT NULL,
"EMPFIRSTNAME" varchar (40) NOT NULL,
"EMPLASTNAME" varchar (40) NOT NULL,
"STREETADDRESS" varchar (50) NOT NULL,
"CITY" varchar (30) NOT NULL,
"POSTALCODE" INT NOT NULL,
"PHONE" INT NOT NULL,
"EMAIL" varchar (50) NOT NULL,
"DATEOFBIRTH" DATE NOT NULL,
"PROFILEIMAGE" BLOB NOT NULL,
"USERNAME" varchar (30) NOT NULL,
"PASSWORD" varchar (30) NOT NULL,
"USERLEVEL" INT NOT NULL,
PRIMARY KEY ("EMPNIC")
);

10
2. Creation of Bookshop GUI
The following installations are required:
1. Adding jCalendar and jDateChooser to
Netbeans palette window
2. Adding derby driver to package ‘Libraries’
3. Adding package rs2xml.jar to ‘Libraries’

The sysadmin registers a sales staff employed at


the Bookshop.
The sales staff logins the system and is allowed to
update his profile.
Sales staff registers a customer.
Sales staff creates on order which is processed.
Payment is recorded.
Stock is updated.
Sysadmin performs the managerial operations:
- Creates an author
- Creates a book
- Adds a book_author
- Creates a supplier
11
- Creates supplier order
- Adds a book_supplier
Creating the EmployeeRegistration GUI:

12
Successful registration of a staff:

13
Staff Login GUI:

14
Successful Staff Login:

15
Admin Dashboard GUI:

16

You might also like