Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views11 pages

Database Assign

The document outlines the creation of a Garden Centre Database for Autumn 2024, detailing tasks including the development of an Entity-Relationship diagram, a data dictionary, SQL commands for schema creation, and role-based access control mechanisms. It emphasizes the importance of adhering to Third Normal Form (3NF) principles to ensure data integrity and efficiency. Additionally, it includes SQL queries for inventory updates, sales summaries, and employee rankings.

Uploaded by

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

Database Assign

The document outlines the creation of a Garden Centre Database for Autumn 2024, detailing tasks including the development of an Entity-Relationship diagram, a data dictionary, SQL commands for schema creation, and role-based access control mechanisms. It emphasizes the importance of adhering to Third Normal Form (3NF) principles to ensure data integrity and efficiency. Additionally, it includes SQL queries for inventory updates, sales summaries, and employee rankings.

Uploaded by

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

Databases

Assignment title: A Garden


Centre Database Autumn 2024

TASK 1:
Analyse the requirements and create an Entity-Relationship diagram (ERD) that represents
entities, their relationships and the cardinalities within the database system. You should
represent the ERD in the UML. Make sure your ER Diagram represents the database design in
Third Normal Form (3NF). Provide a written explanation that justifies the inclusion of entities
and discuss the adherence to 3NF principles.
ANSWER:
According to Smith (2020), a good database system keeps data accurate and helps the business
run smoothly. Chen (1976) introduced the Entity-Relationship (ER) model, which is useful for
showing how data is organized and making sure the database is efficient and free of duplicate
information.

1) CUSTOMER: Stores customer detail which include the name, contact info and purchase
history.
2) SALES: Record all sales transaction.
3) INVENTORY: it stores and keep track of quantities of product.
4) EMPLOYEE: stores employee detail, role and record the workhour.
5) PRIDUCT: Stores details of product sold.
6) WORKSHOP: Contain details of workshops and event.
7) WORKSHOP-ATTENDANCE: links customers to the workshop they attend.
iii) 3NF(Third normal form): is a database schema design approach for relational databases
which uses normalizing principles to reduce the duplication of data ,avoid data
anomalies ,ensure referential integrity and simplify data management. (Jones and Brown,
2018).
In the database schema above there are no transitive dependencies. All attribute are only
dependent on the primary key, each tables contain atomic values and each column contains
unique values.
TASK 2:
Create a data dictionary, detailing attributes, data types and any applicable
constraints. Identify all primary, foreign, and compound keys that you have
created. Show the field length (if applicable) for each attribute used. Make
suitable assumptions where needed.

TABLE ATTRIBUTE DATA TYPE CONSTRAINTS


CUSTOMER CustomerID INT PRIMARY KEY,
AUTO_INCREMENT
Name VARCHAR NOT NULL,
LENGTH(100)
ContactInfo VARCHAR NOT NULL,
LENGTH(200)
PurchaseHistory TEXT
EMPLOYEE EmployeeID INT PRIMARY KEY,
AUTO_INCREMENT
Name VARCHAR NOT NULL,
LENGTH(100)
ContactInfo VARCHAR NOT NULL,
LENGTH(200)
Role VARCHAR NOT NULL,
LENGTH(50)
WorkHours INT NOT NULL
WORKSHOP WorkShopID INT PRIMARY KEY,
AUTO_INCREMENT
Title VARCHAR NOT NULL,
LENGTH(100)
Description TEXT
Date DATE NOT NULL
Time TIME NOT NULL
ExpectedAttendance INT
Equipment TEXT
StaffAssignment TEXT
WORKSHOP- CustomerID INT PRIMARY KEY,
ATTENDANCE FOREIGN KEY
REFERENCES
Customer(CustomerID)
WorkshopID INT PRIMARY KEY,FOREIGN
KEY REFERENCES
Workshop(WorkshopID)
PRODUCT ProductID INT PRIMARY KEY,
AUTO INCREMENT
Name VARCHAR NOT NULL,
LENGTH(100)
Type VARCHAR NOT NULL,
LENGTH(100)
Price DECIMAL NOT NULL
Description TEXT
INVENTORY InventoryID INT PRIMARY KEY,
AUTO INCREMENT
ProductID INT FOREIGN KEY
REFERENCES
Product(ProductID)
Quantity INT NOT NULL
SALES SaleID INT PRIMARY KEY,
AUTO INCREMENT
Date DATE NOT NULL
EmployeeID INT FOREIGN KEY
REFERENCES
Employee(EmployeeID)
Quantity INT NOT NULL
TotalPrice DECIMAL NOT NULL
ProductID INT FOREIGN KEY
REFERENCES
Product(ProductID)
TASK 3:
Write SQL commands to create the database schema based on your ER diagram.
Make sure that all tables, relationships, and constraints are accurately
represented. Enter a range of sample data in all tables (minimum FIVE (5) rows
per table) to show that your tables are capable of holding appropriate data.
ANSWER :
1) CUSTOMER TABLE.

2) EMPLOYEE TABLE:
3)

4)
5)

6
7) SALES
Task 4 – 15 Marks Role-based Access Control Implement role-based access
control mechanisms to safeguard information based on their roles and
responsibilities. Provide justifications for your chosen approaches. • Create
TWO (2) roles (sales and admin) • Create ONE (1) user for each role for
testing. • Identify TWO (2) tables to which privileges will be applied. • Justify
the privileges given to the roles for the chosen tables • Grant appropriate
access to the TWO (2) tables for the TWO (2) roles • Show output from tests
to demonstrate it works

i)

Roles were created for sales and admin and assign to a specific user with a username and
password .
 For sales privileges a sale staff is only allowed to view, add, and update sales records other
act like delete etc are not allowed.

ii)
-- Admin Role: This role is for administrators who need full access to all tables and the ability to grant
privileges to other users.

Task 5 – 20 Marks SQL queries


a) Write a SQL query to update the inventory to reflect the latest pricing after a
supplier price change. This query increases the price of all gardening tools by
10% to adjust for an increase in supplier costs.
b) Write a SQL query to retrieve the highest priced item from each of the
following categories: plants, gardening tools and accessories. Provide the
product name, type, price and a brief description for each. c) Write a SQL query
to summarise the total sales transactions for a specific past month, breaking
down the data by item category, including quantities sold and total revenue per
category. d) Write a SQL query to find all upcoming workshops and events
within the next month, including the titles, dates, times, and the current
number of registered participants. e) Write a SQL query to retrieves and rank
employees based on the total revenue they’ve generated from these
transactions up until a specific date
REFERENCES:

Chen, P. P. (1976) 'The Entity-Relationship Model - Toward a Unified View of


Data', ACM Transactions on Database Systems, 1(1), pp. 9-36.

Jones, A. and Brown, B. (2018) 'The Impact of Database Normalization on


Performance', Journal of Database Management, 34(2), pp. 115-123.

MySQL (2024) 'MySQL 8.0 Reference Manual', MySQL. Available at:


https://dev.mysql.com/doc/refman/8.0/en/ (Accessed: 15 July 2024).

MySQL (2024) 'SQL Syntax', MySQL. Available at:


https://dev.mysql.com/doc/refman/8.0/en/sql-syntax.html (Accessed: 15 July
2024).

Smith, J. (2020) Database Systems: Design, Implementation, and Management.


12th edn. Boston: Cengage Learning.

You might also like