Entity Type Attributes of the Entity Key
Books ISBN, Title, Author, Genre, PublicationDate, Price, ISBN (Primary Key)
QuantityAvailable
Customers CustomerID, Name, ShippingAddress, ContactNumber, Email CustomerID (Primary Key)
Orders OrderID, CustomerID (FK), OrderDate, TotalAmount, OrderID (Primary Key), CustomerID
PaymentStatus (Foreign Key)
Shipping ShippingID, OrderID (FK), ShippingAddress, DeliveryStatus, ShippingID (Primary Key), OrderID
TrackingNumber (Foreign Key)
Reviews eviewID, CustomerID (FK), ISBN (FK), Rating, ReviewText ReviewID (Primary Key),
CustomerID (Foreign Key), ISBN
(Foreign Key)
OrderDetails OrderDetailID, OrderID (FK), ISBN (FK), Quantity OrderDetailID (Primary Key),
OrderID (Foreign Key), ISBN
(Foreign Key)
Relationship Type Entities connected bythe relationship Cardinality Relationship attribute
type
Purchases Customers - Orders 1:N CustomerID (FK)
Contains Orders - OrderDetails 1:N OrderID (FK)
Includes OrderDetails - Books N:1 ISBN (FK)
Ships Orders - Shipping 1:1 OrderID (FK)
Reviews Customers - Reviews 1:N CustomerID (FK)
ReviewedBy Books - Reviews 1:N ISBN (FK)
a) Draw the EER Diagram
Create the tables on SQL server management Studio and populate them with at least 10
rows.(
b) Write SQL queries to find the following:
• Write the relational algebra expression to find:
•
• [Link] who purchased more than 3 books:
• $\sigma_{SUM(Quantity) > 3} (\pi_{Name} (Customers \bowtie Orders \bowtie OrderDetails))$
• [Link] of books in "Fiction" genre ordered by at least one customer:
• $\pi_{Title} (\sigma_{Genre='Fiction'} (Books) \bowtie OrderDetails \bowtie Orders)$
• [Link] and emails of customers who placed orders for more than 5 books:
• $\sigma_{SUM(Quantity) > 5} (\pi_{Name, Email} (Customers \bowtie Orders \bowtie OrderDetails))$