0% found this document useful (0 votes)
15 views8 pages

Assignment Database No.4

Assignment example format

Uploaded by

Kaipulla 25
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
15 views8 pages

Assignment Database No.4

Assignment example format

Uploaded by

Kaipulla 25
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 8

1) Entity Identification and Attributes

Customer : Tracks Customer Information.


- Attributes : CustomerID (Primary Key), FirstName, LastName, Email, Phone, Address,
DateOfBirth, LoyaltyPoints.

Product : Stores details about each product.


- Attributes : ProductID (Primary Key), ProductName, ProductCategory, Brand, Price,
StockQuantity, SupplierID (Foreign Key).

Order : Holds order information.


- Attributes : OrderID (Primary Key), CustomerID (Foreign Key), OrderDate, TotalAmount,
PaymentStatus, ShippingAddress, StoreID (Foreign Key).

OrderDetails : Tracks which product were ordered and in what quantities.


- Attributes : OrderDetailID (Primary Key), OrderID (Foreign Key), ProductID (Foreign Key),
Quantity, UnitPrice, Discount.

Supplier : Contains information about product suppliers.


- Attributes : SupplierID (Primary Key), SupplierName, ContactPerson, Phone, Email, Address.

Payment : Customer payment.


- Attributes : PaymentID (Primary Key), OrderID (Foreign Key), PaymentDate,
PaymentMethod, Amount.

SalesPerson : Insert the information about the payment and inventory.


- Attributes : SalesPersonID (Primary Key), FirstName, LastName, Email, Phone, HireDate,
StoreID (Foreign Key).

Store : Place where inventory is kept.


- Attributes : StoreID (Primary Key), StoreName, Location, ManagerID, ContactNumber.

2) Relationship and cardinality

Product and Supplier


Relationship : One supplier can supply multiple products, but a product is supplied by only
one supplier.
Cardinality : One to Many

Customer and Order


Relationship : A customer can make many purchases but each order is place by on customer.
Cardinality : One to Many

Order and OrderDetails


Relationship : Each order can have many products but each item belongs to a single order.
Cardinality : One to Many
Product and OrderDetails
Relationship : A product can be ordered in multiple orders but each order details is for only
one products
Cardinality : One to Many

Order and Payment


Relationship : Each order have one payment and each payment is for one order.
Cardinality : One to One

Store and SalesPerson


Relationship : Each store has many Sales person but each salesperson work on one store.
Cardinality : One to Many

Store and Order


Relationship : A store can process many orders but each order is linked to only one store.
Cardinality : One to Many

Salesperson and Order


Relationship : A salesperson handle many customer order but each order is handled by only
one salesperson.
Cardinality : One to Many

3) Entity Relationship Diagram (ERD)


4) Relationship Scheme

Product
Schema : Product( ProductID, ProductName, Category, Price, StockQuantity, SupplierID )

Supplier
Schema : Supplier( SupplierID, SupplierName, ContactName, ContactEmail, ContactPhone )

Customer
Schema : ( CustomerID, CustomerName, Email, Phone, ShippingAddress )

Order
Schema : Order( OrderID, OrderDate, TotalAmount, CustomerID, StoreID, SalesPersonID )

OrderDetails
Schema : OrderDetails( OrderDetailsID, OrderID, ProductID, Quantity, PriceAtTimeOfOrder)

Payment
Schema : Payment( PaymentID, OrderID, PaymentMethod, PaymentDate, AmountPaid )

Store
Schema : Store( StoreID, StoreName, StoreLocation, ManagerName )

SalesPerson
Schema : SalesPerson( SalesPersonID, SalesPersonName, StoreID, Email, Phone)

5) SQL Table Creation

The Tables I have created as the database name is Assignment and the tables are Customer,
Employee, Order, OrderDetails, Payment, Product, Shipment, Supplier.
6) Sample Records

Customer Table

Supplier Table

Product Table
Order Table

Order Details Table

Payment Table

Employee Table
Shipment Table
7) SQL Queries

This Picture is about the query that tell “ SELECT * FROM Customer; ” shows the data of the
customer.

This Picture is about the query that tell


“SELECT EmployeeName, Salary FROM Employee ORDER BY Salary DESC; ” shows the
employee name and salary by desending order.
This Picture is about the query that tell “ SELECT SUM(Amount) AS TotalPayments FROM
Payment; ” show the total sum of payment recieved.

This Picture is about the query that tell “SELECT * FROM `Order` WHERE CustomerID =
(SELECT CustomerID FROM Customer WHERE CustomerName = 'John Doe'); ” shows the
order with customer id by the name Jack Daniels.

This Picture is about the query that tell “ ALTER TABLE Shipment ADD COLUMN
TrackingNumber VARCHAR(50); ” shows the shipment table is added an extra column name
TrackingNumber.

You might also like