This document outlines the steps to create a database for an online bookstore, including conceptualizing the project, identifying relationships between entities like books, authors, customers and orders, creating an entity relationship diagram, defining attributes and data types, establishing primary and foreign keys, creating relevant tables in SQL, and implementing relationships between tables.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
11 views
How To Think of Database Online Book Store
This document outlines the steps to create a database for an online bookstore, including conceptualizing the project, identifying relationships between entities like books, authors, customers and orders, creating an entity relationship diagram, defining attributes and data types, establishing primary and foreign keys, creating relevant tables in SQL, and implementing relationships between tables.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3
Level 2 Database E.
Kawthar M
Let's walk through a simple example of a project involving a database for
an online bookstore. We'll go through the steps outlined earlier. Step 1: Project Conceptualization Project Scope: Create a database for an online bookstore to manage books, authors, customers, and orders. Objectives: Allow customers to browse and purchase books, track inventory, and manage orders. Step 2: Identify Relationships Entities: Book, Author, Customer, Order Relationships: One Author can write Many Books (One-to-Many) One Customer can place Many Orders (One-to-Many) One Order can contain Many Books (Many-to-Many) Step 3: Entity-Relationship Diagram (ERD) Step 4: Attributes and Data Types Book: book_id (PK), title, price, ISBN, publication_year Author: author_id (PK), name, birth_date, country Customer: customer_id (PK), name, email, address Order: order_id (PK), customer_id (FK), order_date Book_Order: book_id (FK), order_id (FK), quantity
Step 5: Primary and Foreign Keys
Primary keys are underlined (PK), and foreign keys (FK) establish relationships between tables. Step 6: Creating Tables (SQL Example) CREATE TABLE Author ( author_id INT PRIMARY KEY, name VARCHAR(100), birth_date DATE, country VARCHAR(50) );
CREATE TABLE Book (
book_id INT PRIMARY KEY, title VARCHAR(200), price DECIMAL(10, 2), ISBN VARCHAR(20), publication_year YEAR, author_id INT, FOREIGN KEY (author_id) REFERENCES Author(author_id) );
CREATE TABLE Customer (
customer_id INT PRIMARY KEY, name VARCHAR(100), email VARCHAR(100), address VARCHAR(200) );
The author_id in the Book table establishes a one-to-many relationship with the Author table. The customer_id in the Order table establishes a one-to-many relationship with the Customer table. The book_id and order_id in the Book_Order table create a many- to-many relationship.