Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i wand draw erd for tihse system Entities: 1 . Book 2 . Author 3 . Publisher 4 . Genre 5 . Customer 6 .
i wand draw erd for tihse system
Entities:
Book
Author
Publisher
Genre
Customer
Order
Relationships:
An Author can write multiple Books OnetoMany
A Book is written by one Author ManytoOne
A Book is published by one Publisher ManytoOne
A Publisher can publish multiple Books OnetoMany
A Book can belong to multiple Genres ManytoMany
A Genre can have multiple Books ManytoMany
A Customer can place multiple Orders OnetoMany
An Order can contain multiple Books OnetoMany
A Book can be included in multiple Orders ManytoMany
An Order is placed by one Customer ManytoOne
Logical Design: SQL Coding
Book table
CREATE TABLE Book
bookid INT PRIMARY KEY,
title VARCHAR
isbn VARCHAR
publisherid INT,
FOREIGN KEY publisherid REFERENCES Publisherpublisherid
;
Author table
CREATE TABLE Author
authorid INT PRIMARY KEY,
name VARCHAR
;
Publisher table
CREATE TABLE Publisher
publisherid INT PRIMARY KEY,
name VARCHAR
;
Genre table
CREATE TABLE Genre
genreid INT PRIMARY KEY,
name VARCHAR
;
Customer table
CREATE TABLE Customer
customerid INT PRIMARY KEY,
name VARCHAR
email VARCHAR
address VARCHAR
;
Order table
CREATE TABLE Order
orderid INT PRIMARY KEY,
customerid INT,
orderdate TIMESTAMP,
FOREIGN KEY customerid REFERENCES Customercustomerid
;
BookGenre table for manytomany relationship between Book and Genre
CREATE TABLE BookGenre
bookid INT,
genreid INT,
PRIMARY KEY bookid genreid
FOREIGN KEY bookid REFERENCES Bookbookid
FOREIGN KEY genreid REFERENCES Genregenreid
;
OrderItem table to represent the manytomany relationship between Order and Book
CREATE TABLE OrderItem
orderid INT,
bookid INT,
quantity INT,
PRIMARY KEY orderid bookid
FOREIGN KEY orderid REFERENCES Orderorderid
FOREIGN KEY bookid REFERENCES Bookbookid
;
AuthorBook table to represent the manytomany relationship between Author and Book
CREATE TABLE AuthorBook
authorid INT,
bookid INT,
PRIMARY KEY authorid bookid
FOREIGN KEY authorid REFERENCES Authorauthorid
FOREIGN KEY bookid REFERENCES Bookbookid
;
The Book table stores information about books, including their title, ISBN, and the publisher they belong to
The Author table stores information about authors, including their name.
The Publisher table stores information about publishers, including their name.
The Genre table stores information about book genres, including their name.
The Customer table stores information about customers, including their name, email, and address.
The Order table stores information about orders placed by customers, including the order date.
The BookGenre table represents the manytomany relationship between books and genres.
The OrderItem table represents the manytomany relationship between orders and books.
The AuthorBook table represents the manytomany relationship between authors and books.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started