You are on page 1of 34

GROUP ASSIGNMENT-MARKING SCHEME

TECHNOLOGY PARK MALAYSIA


CT043-3-1-IDB
INTRODUCTION TO DATABASES
NPT1F2309IT
Title Page

HAND OUT DATE: 21 Jan 2024


HAND IN DATE: 04 Mar 2024
WEIGHTAGE: 70%

Lecturer name: Sushil Bhattarai, Mukunda Bhattarai

Student Id Student Name

Hemraj Budha NP069673

Ayushree Lamichhane NP069661

Ashlok Kumar NP069658


Chaurasiya
Contents

Title Page..........................................................................................................................................i

1. Introduction..................................................................................................................................1

2. Database and Database management system...............................................................................2

2.1 Disadvantages of file-based system.......................................................................................2

2.2 Advantages of Database.........................................................................................................3

2.3 Advantages of DBMS............................................................................................................4

3.ERD Diagram...............................................................................................................................4

4.TU's E-Bookstore: Key Business Rules.......................................................................................6

5.Normalization...............................................................................................................................7

5.1 UNF (Unnormalized Normal Form)......................................................................................8

5.2 1NF (First Normal Form).......................................................................................................9

5.3 2NF (Second Normal Form)................................................................................................11

5.4 3NF (Third Normal Form)...................................................................................................12

6. Database Schema / Diagram......................................................................................................13

7. Data Dictionary..........................................................................................................................13

8. SQL (Structured Query Language)............................................................................................17

8.1 DDL (Data Definition Language)........................................................................................17

8.2 DML (Data Manipulation Language)..................................................................................17

9. DDL Statements.........................................................................................................................18

10. DML Statements......................................................................................................................20

11. DML Questions.......................................................................................................................24

11.1 Individual components (Ayushree Lamichhane NP069661).............................................24

11.3 Individual Components (Ashlok Kumar Chaurasiya NP069658)......................................26

ii
11.3 Individual Components (Hemraj Budha NP069673).........................................................27

12. Conclusion...............................................................................................................................29

13.References.................................................................................................................................30

14. Workload matrix......................................................................................................................30

iii
1. Introduction
Tribhuvan University (TU) has initiated a creative endeavor to improve the accessibility and
availability of reading materials for its large student and staff community, in response to the
changing academic landscape and the increasing demand for a varied range of educational
resources. TU is going to be the first to build an online e-Bookstore System, utilizing
contemporary technology to simplify the acquisition and distribution of books and reading
materials, in recognition of the shortcomings of the current book procurement procedure.

The goal of this system is to smoothly combine the ordering of books, inventory control,
customer registration, and online purchasing operations. TU hopes to establish a setting where
instructors, staff, and students can quickly and conveniently access the newest publications and
resources with a few clicks by utilizing digital technology.

The goal is to transform TU's reading landscape, making educational resources more accessible,
diverse, and tailored to the dynamic needs of its academic community.

iv
2. Database and Database management system
2.1 Disadvantages of file-based system
In the file-based system, there are a few drawbacks. In file, many disadvantages have led to the
development and adoption of more advanced database management systems in today's world.
Here are some disadvantages of file-based systems which are very bad for database management
systems.

1) Data redundancy:

Data redundancy is the major problem of file-based systems. data redundancy is defined as the
repetition of the same data in different files. Data redundancy repeats duplicate data across
multiple files, which causes storage problems.

2)Security and access control of data

In file-based systems, there is a high chance of data access and control of data by unknown
persons. It is challenging to implement fine-grained access restrictions, making it easier for
unauthorized persons to access or modify data.

4) Storage issue

As the volume of data increases in file-based systems, we need to struggle to store data
efficiently. While storing data in file-based systems we need to create different file names for the
data type.

5) limited data sharing

Sharing data among different users, organizations, or persons is difficult in a file-based system.
In a file-based system, there are too many files which is very hard to share with others due to the
huge amount of data in a single file.

v
2.2 Advantages of Database.
The database provides us many advantages that contribute to efficient and reliable man of data.
Several benefits help us to maintain our data properly in data management. The following points
are the advantages of a database which plays a good role in data management.

1) Data integrity

It is a good feature of the database in this feature database enforces rules and constraints to
ensure the good accuracy of stored data information. This helps to prevent errors and foster trust
in the data.

2) Data security

In the database, we can get good security features which is very useful in database. In this
feature, databases offer robust security features, including access controls, data encryption, etc.
These measures help to protect sensitive information from unauthorized access of data from
unknown persons.

3) Easy to access from anywhere

This is a very important thing in a database. It allows users to access data from anywhere at any
time. It allows multiple users to access it at the same time interval. By using this feature, users
can modify data simultaneously while maintaining data consistency through mechanisms like
transactions.

4) Data Recovery and Backup

This feature is the fundamental feature of a database. This feature helps to do regular backups of
data to safeguard against data loss due to accidental errors or deletion of data by hardware
failures or unforeseen events. This feature also helps to use data during a crash of the system.

5) Centralized management of data

The database provides a centralized and standardized way of managing data. This feature helps
to manage data in a centralized way. With this feature administration, updates, and maintenance
of data is easy to do.

vi
2.3 Advantages of DBMS
1. It is highly designed to handle large amounts of data in a DBMS system. It is easy to
access and recover data needed from any place in the world.

2. There is no chance of data loss or data crash if our system gets down but, in a file,-based
system, every data is in the file if something happens everything gets lost and cannot be
recovered.

3. It is easier to apply access constraints in database systems so that only authorized users
can access the data. Each user has a different set of access thus data is secured from
issues such as identity theft, data leaks, and misuse of data.

Function of DBMS

1. Backup and recovery:

To keep data for a long time DBMS provides Data backup and recovery options to keep it
safe for future use. It states that in case of data loss, DBMS helps us to recover it if the
system fails and gets crashed, our database can be recovered.

2. Multi-user access control: -

This is another feature that provides us with DBMS to access data by multiuser while in
need. With these features, more than one user can access data from any place at any time
without any problem. It also follows the ACID property, so the database will be
consistent while multiple users are accessing it concurrently.

3.ERD Diagram
An Entity-Relationship Diagram (ERD) shows the relationships between entities in a database
graphically. It is an essential tool for database design, helping to visualize the logical structure
and connections between the database's different parts. Generally, each entity in the diagram
represents a table in the database, and the connections or associations between these tables are

vii
represented by the lines. Understanding the relationships and organization of data entities within
the database is made easier by this visual representation.

Fig: ER Diagram

The major elements of ERD:

Entities:

Entities are used to symbolize concepts or real-world objects for which data is kept in a database
in an Entity-Relationship Diagram (ERD). Each entity is represented by a table in the database
and is typically defined by rectangles.

Attributes:

The properties or traits of these entities are indicated by attributes, which are represented in Oval
Shape. For example, attributes for an entity "Members" might be identifiers like MemberId,
Name, Address, Phone and so on.

Relationship:

It shows how different entities are related to one another. In relationship entity rectangles are
connected by lines to represent these associations. There are many different types of

viii
relationships, including one-to-one, one-to-many, and many-to-many, which indicate the
cardinality of the relationship.

Cardinality:

It shows how many instances of one entity are connected to a single instance of another. One-to-
one, one-to-many, and many-to-many cardinality types are common and provide information
about the database's relational structure.

4.TU's E-Bookstore: Key Business Rules


Eligibility:

 Only individuals affiliated with TU, such as students and staff members, are eligible to
make purchases from the e-bookstore.

Selection:

 The e-bookstore provides a wide range of books and materials spanning different genres
and categories.
 Its availability is not restricted by physical limitations, unlike conventional bookstores.

Purchasing:

 Purchases are made entirely online.


 This system manages a database of books, materials, and their availability. Registered
users can browse, search, filter products, add to cart, and complete secure online
payments and order confirmation.

User Accounts:

 Available for purchase only to registered students and employees.


 The system manages user accounts with purchase history and order details.

User Engagement:

 Users can rate and review books and materials and provide valuable feedback that
improves the user experience.

Security and Support:

ix
 This system prioritizes the security and privacy of your personal and financial
information.
 Customer service is available to help resolve issues related to purchases, orders, or
accounts.

Content Management:

 The e-bookstore works together with publishers and suppliers to ensure they have a
varied and current collection of books.
 The inventory is constantly being refreshed to show the latest arrivals of books and
materials.

5.Normalization
It is a technique for arranging data in a database to minimize redundant information and
dependencies. It breaks the large table into smaller ones. It also creates relationships between
tables using the foreign key.

The objective of Normalization:

 The main objective is to organize data in tables.


 It helps maintain and create relations between tables.
 One value should be at only one place.
 Decrease data redundancy and dependency.

Mainly, three forms of normalization are given below:

1) UNF (Unnormalized Normal Form)


2) 1NF (First Normal Form)
3) 2NF (Second Normal Form)
4) 3NF (Third Normal Form)

x
5.1 UNF (Unnormalized Normal Form)
It is a simple form that consists of multiple values in a single cell. It doesn’t establish the relation
and stores data in a table randomly. In the above scenario, we normalize the table up to 3NF
starting from this normal form. Let’s go to the example.

Publisher Publisher Publisher Email Phone


Id Name Address
P100 Hemraj Lalitpur, Bhaktapur hemraj@gmail. 9745705
com 226
P101 Ashok Kathmandu, Butwal ashok@gamil.c 9868565
om 007

Table 1. 1: Unnormalized data of publisher.

Member Member Member Member Email Phone


Id (PK) First Name Second Address
Name
C120 Ayushree Lamichhane Bhaktapur, ayushree@gmail.co 9745893412
Lalitpur m
C121 Alice Joshi Malaysia, alice@gmail.com 9868233547
France
Table 1. 2: Unnormalized data of Member.

Manager Manager Manager Phone


Id(PK) Name Address
P100 Prabin Lalitpur, Butwal 9806612801
P101 Ashok Kathmandu, Kailali 9868565007
Table 1. 3: Unnormalized data in Manager.

Book Title Author Price Quantity Publication Delivered


Id (PK) Date Status
B001 Romeo William $ 100 10, 30 19 Jan 2005 Delivered
Juliet Shakespeare
B002 Muna Laxmi Prasad Rs 150 20, 40 20 Jan 2015 Delivered
Madan Devkota
Table 1. 4: Unnormalized data in the Book table.

Category ID Category Name


1C001 Romantic, Science Fiction
1C002 Horror

xi
Order Order Quantity
Id (PK) Date
100 22 Feb 2024 14, 12
101 25 Feb 2024 15
Table 1. 5: Unnormalized data in order table

Invoice Quantity Receipt Total


Id (PK) s Payment
Id
1001 13,12 2001 20000,
1000
1002 14 2002 40000
Table 1. 6: Unnormalized data in Invoice table.

Feedback Comment Rating Receipt Total


Id (PK) s Payment
F001 Satisfied 8, 5 Id (PK)
2001 20000
F002 Neutral, satisfied 5
2002 40000
Table 1. 7: Unnormalized data in Feedback.

5.2 1NF (First Normal Form)


 There should be a single cell in each table cell.
 Each row must be unique.

Below tables are in the 1NF


Publisher Publisher Publisher Email Phone
Id Name Address
P100 Hemraj Lalitpur hemraj@gmail.com 9745705226
P100 Hemraj Bhaktapur hemraj@gmail.com 9745705226
P101 Ashok Kathmandu ashok@gamil.com 9868565007
P101 Ashok Butwal ashok@gamil.com 9868565007
Table 2. 1: 1NF of publisher

xii
Member Member Member Member Email Phone
Id (PK) First Name Second Address
Name
C120 Ayushree Lamichhane Bhaktapur ayushree@gmail.com 9745893412
C120 Ayushree Lamichhane Lalitpur ayushree@gmail.com 9745893412
C121 Alice Joshi Malaysia alice@gmail.com 9868233547

C121 Alice Joshi France alice@gmail.com 9868233547


Table 2. 2: 1Nf of Member

Manager Manager Manager Phone


Id(PK) Name Address
P100 Prabin Lalitpur 9806612801
P101 Ashok Kathmandu 9868565007
Table 2. 3: 1NF of Manager

Book Title Author Price Quantity Publication Delivered


Id (PK) Date Status
B001 Romeo William $ 100 10 19 Jan 2005 Delivered
Juliet Shakespeare
B001 Romeo William $ 100 30 19 Jan 2005 Delivered
Juliet Shakespeare
B002 Muna Laxmi Prasad Rs 150 20 20 Jan 2015 Delivered
Madan Devkota
Table 2. 4: 1Nf of Book

Category ID Category Name Feedbac Comment Rating


k
1C001 Romantic
Id (PK)
1C001 Science Fiction F001 Satisfied 8
1C001 Horror
F002 Neutral 5
Table 2. 5: 1NF Of category Table 2.
6: 1NF of Feedback

xiii
Order Order Quantity Cart Cart Cart
Id (PK) Date Id (PK) Date Quantity
100 22 Feb 2024 14 1C01 23 Feb 2024 4

100 22 Feb 2024 12 1C01 24 Jan 2024 4

101 25 Feb 2024 15 1C02 25 Feb 2024 2


Table 2. 7: 1NF of Order Table 2. 8: 1NF Of Cart

5.3 2NF (Second Normal Form)


 Should be in 1NF.
 The primary key is the only functional dependency of all non-key attributes.
 All tables are already described in 1NF. So, we will show the only relation tables.

Below are the tables which change into 2NF:


Order Order Quantit Book Publisher
Id (PK) Date y Id (FK) Id (FK)
100 22 Feb 2024 14 B001 P100
101 25 Feb 2024 15 B002 P101
Table 3. 1: 2NF of Order details

Feedback Comment Rating Book Members


Id (PK) Id Id (FK)
(FK)
F001 Satisfied 8 B001 C120
F002 Neutral 5 B002 C121

Table 3. 2: 2NF Of feedback

Receipts Total Manage Members


Id (PK) Payment r Id (FK)
Id (FK)
2001 20000 P100 C120
2002 40000 P101 C121

xiv
5.4 3NF (Third Normal Form)
 Should be in 2NF.
 Remove transitive dependencies.
 Only the primary key should be the basis for non-key attributes.
 All tables are already described on 1NF and 2NF. We will show only the relation table.

Below are the tables that change into 3NF:

xv
6. Database Schema / Diagram

Fig: Database Diagram

7. Data Dictionary
1) Publisher

Name Data Type Constraints Description

Publisher Id Varchar (12) Primary key, not This column will hold the primary
null key of the table.
[Name] Varchar (20) Not null This column will hold the name of
the Publisher.
[Address] Varchar (20) Not null This column will hold the address
of the publisher
Email Varchar (20) Null This column will hold the email of
the publisher.
Phone Varchar (20) Not null The column will hold the contact
number of the publisher.

2) Members

Name Data Type Constraints Description

xvi
Members Id Varchar (12) Primary key, not null This column will hold the
primary key of the table.
[First Name] Varchar (20) Not null This column will hold the first
Name of the Member.
[Second Name] Varchar (20) Not null This column will hold the second
name of the member.
[Address] Varchar (20) Null This column will hold the address
of the member.
Phone Varchar (20) Not null This column will hold the contact
number of the member.

3) Book

4) Name Data Type Constraints Description

Book Id Varchar (12) Primary key, not This column will hold the
null primary key of the table.
Title Varchar (20) Not null This column will hold the title of
the Book.
Author Varchar (20) Not null This column will hold the author
of the Book.
Price Decimal Not null This column will hold the price
(18,2) of the Book.
Publication Date Not null This column will hold the contact
Date number of the member.
Publisher Id Varchar (12) Foreign key, not null This column will connect another
table Publisher.

4) Category

Name Data Type Constraints Description

Category Id Varchar (12) Primary key, not null This column will hold the
primary key of the table.
Category Name Varchar (20) Not null This column will hold the name
of the category.
Book Id Varchar (20) Foreign Key, not This column will connect another
null table Book.

5) Order Details

Name Data Type constraints Description


Order Id Int Primary Key, not This column will hold the
null primary key of the table.
Order Date date Not null This column will hold the order
xvii
date.
Quantity Int Not null This column will hold the
quantity of the ordered books.
Book Id Varchar (20) Not null This column will connect another
table Book.
Publisher Id Varchar (20) Not null This column will also connect
another table Publisher.
Delivered Varchar (50) Not null This column will hold the status
status of delivery of the book.

6) Cart

Name Data Type Constraints Description

Cart Id Varchar (12) Primary key, not null This column will hold the
primary key of the table.
Cart Date Date Not null This column will hold the date of
the cart.
Cart Quantity Int Not null This column will hold the
quantity of the cart.
Book Id Varchar (12) Foreign Key, not null This column will connect the
other table Book.
Members Id Varchar (12) Foreign key, not null This column will also connect
the other table Member.

7) Feedback
Name Data Type Constraints Description

Feedback Id Int Identity Primary Key, not null This column will hold the
(1,1) primary key of the table.
Comment Varchar (20) Null This column will allow members
to comment.
Rating Int Null This column will allow members
to provide ratings.
Book Id Varchar (12) Foreign Key, not null This column will connect
another table Book.
Members Id Varchar (12) Foreign key, not null This column will also connect
the other table Member.

8) Invoice

Name Data Type Constraints Description

Invoice Id Int Identity Primary Key, not null This column will hold the

xviii
(500,1) primary key of the table.
Invoice date Date Not null This column will hold the
invoice date.
Quantity Int Not Null This column will hold the
quantity of the invoice.
Book Id Varchar (12) Foreign Key, not null This column will connect
another table Book.
Members Id Varchar (12) Foreign key, not null This column will also connect
the other table Members.
Order Id Int Foreign key, not null This column will also connect
the other table Order Details.

9) Receipts

Name Data Type Constraints Description

Receipts Id Int Identity Primary Key, not null This column will hold the
(1000,1) primary key of the table.
Total Payment Decimal Not null This column will hold the
(15,2) Payment of the ordered books.
Invoice Id Int Foreign Key, Not Null This column will connect
another table Invoice.
Publisher Id Varchar (12) Foreign Key, not null This column will connect
another table Publisher.
10) Warehouse

Name Data Type Constraints Description

Id Int Identity Primary Key, not null This column will hold the
(800,1) primary key of the table.
Quantity Int Not null This column will hold the
Quantity of the Books.
Location Varchar (30) Not Null This column will hold the
location of the warehouse.
Book Id Varchar (12) Foreign Key, not null This column will connect
another table Book.
Manager Id Varchar (12) Foreign Key, not null This column will connect
another table Manager.

11) Customer

Name Data Type Constraints Description

xix
Customer Id Varchar (12) Primary Key, not null This column will hold the
primary key of the table.
Customer Varchar (100) Not null This column will hold the name
Name of the Customer.
Customer Varchar (100) Not null This column will hold the email
Email of the Customer.
Registration date Not null This column will hold the
date registration date of the customer.

8. SQL (Structured Query Language)


It stands for structured Query Language. It is a query/command that is used to create, insert,
update, and delete the table or database.

Two types of SQL commands.

1. DDL (Data Definition Language)


2. DML (Data Manipulation Language)
3. DCL (Data Control Language)
4. TCL (Transaction Control Language)
5. DQL (Data Query Language)

Mainly, we used two query languages. They are DDL and DML

8.1 DDL (Data Definition Language)


It is used to create, alter, drop, and truncate the table.
Some commands of the DML are used. They are:

1. CREATE -It is used to create the table.


2. ALTER -It is used to modify the table or database.
3. DROP- It is used to remove the entire table and database.
4. TRUNCATE- It removes the data from the table and initializes the serial number.

8.2 DML (Data Manipulation Language)


It is used to insert, update, delete, and read the data in the table.
Some commands of the DML are used. They are:

1. INSERT- inserting the data into the table.


2. UPDATE – modify or change the existing data in the table.

xx
3. DELETE – Remove the data from the table and don’t initialize the serial number.
4. SELECT – Reads the data from the table.

9. DDL Statements
 Create publisher table command.

 Create Customer table command.

 Create members tale command.

 Create Book Store Manager Table command.

xxi
xxii
 Create Book table Command.

 Create Warehouse table command.

 Create Order Details command.

 Create Cart table command.

xxiii
 Create Feedback table command.

 Create Invoice table Command.

 Create Receipts Table Command.

10. DML Statements


 Inserting data into Publisher Table.

xxiv
 Inserting data into the Customer table.

 Inserting data into Members table.

 Insert data into the Manager table.

 Inserting data into the Book table.

xxv
 Inserting data into Warehouse Table.

 Inserting data into Order Details Data.

 Inserting data into the Cart table.

 Inserting data into the Feedback Table.

xxvi
 Inserting data into Invoice Table.

 Inserting data into the Receipts Table.

Select all the tables.

xxvii
11. DML Questions
11.1 Individual components (Ayushree Lamichhane NP069661)
 A list of the latest books sent by various publishers based monthly.

xxviii
 A list of books ordered by store managers from various publishers based on a monthly basis.

 Produce a record of invoices for various publishers. The invoice consists of invoice number,
invoice date, publisher’s names & addresses, and total amount to be paid.

xxix
11.3 Individual Components (Ashlok Kumar Chaurasiya NP069658)
 A list of all customer's records who are registered members in the TU E-Bookstore. The
record of each member should show the member’s identification number, first name and
last name, address, and contact number.

 A list of purchased books that have been delivered to members. The list should show
member identification number, first name and last name, address, contact number, book
serial number, book title, quantity, date.

 List of books based on specific categories (e.g. Science Fiction, Romantic, History,
Horror, etc.). The list should show type of book category, book serial number, book title
and quantity.

xxx
11.3 Individual Components (Hemraj Budha NP069673)
 Produce a list of the total number of books for each category of books.

xxxi
 A list of total books and their total price as added by members in shopping.

 Produce a list of books with the number of various feedback for books based on scores
(1-10 which is 0= terrible, 10= masterpiece) rated by members.

xxxii
12. Conclusion
To sum up, Tribhuvan University (TU) has created an e-Bookstore System to address the lack of
reading materials by offering a contemporary platform for books and educational resources
purchases. Purchases made by customers, feedback requests, and book procurement are all
streamlined by this system. Clients are able to add products to their cart, securely process
payments, become members, and access a multitude of resources. The system allows for user
feedback while simultaneously maintaining comprehensive records on books, inventory,
customers, and orders. Through effective administration and better resource access, it is expected
to significantly improve TU's staff and students' educational experience overall.

xxxiii
13.References
Adler, T. (n.d.). Data Dictionary. Retrieved from Scribd:
https://www.scribd.com/document/663109111/Data-Dictionary

Broer, M. (n.d.). Retrieved from Studocu: https://www.studocu.com/my/document/asia-pacific-


university-of-technology-and-innovation/software-engineering/das-part-1-group-assignment/
41122014

Grauer, A. (n.d.). chapter9 database 9629 .pptx . Retrieved from Course Hero:
https://www.coursehero.com/file/41947348/chapter9-database-9629pptx/?cv=1

14. Workload matrix.

Team Member Name Work done Tasks


Percentage
Hemraj Budha 34% Normalization, Data
(NP069673) Dictionary, SQL, DDL
Ayushree Lamichhane 33% ER Modeling,
(NP069661) Business rules,
Database Diagram
Ashlok Kumar 33% Introduction to
Chaurasiya database and DBMS,
(NP069658) DML

xxxiv

You might also like