CREATE TABLE Books (
BookID INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL
);
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE,
phone VARCHAR(15)
);
CREATE TABLE Orders (
OrderID INT PRIMARY KEY AUTO_INCREMENT,
CustomerID INT,
order_date DATE NOT NULL,
total_amount DECIMAL(10, 2) NOT NULL,
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
);
CREATE TABLE Inventory (
InventoryID INT PRIMARY KEY AUTO_INCREMENT,
BookID INT,
stock INT NOT NULL,
FOREIGN KEY (BookID) REFERENCES Books(BookID)
);
INSERT INTO Books (title, author, price)
VALUES
('The Great Gatsby', 'F. Scott Fitzgerald', 10.99),
('1984', 'George Orwell', 8.99),
('To Kill a Mockingbird', 'Harper Lee', 12.99),
('The Catcher in the Rye', 'J.D. Salinger', 9.99),
('Moby Dick', 'Herman Melville', 14.99);
INSERT INTO Customers (name, email, phone)
VALUES
('John Doe', 'john@example.com', '123-456-7890'),
('Jane Smith', 'jane@example.com', '987-654-3210'),
('Alice Johnson', 'alice@example.com', '555-123-4567'),
('Bob Brown', 'bob@example.com', '444-555-6789'),
('Charlie Davis', 'charlie@example.com', '333-666-9876');
INSERT INTO Orders (CustomerID, order_date, total_amount)
VALUES
(1, '2023-02-01', 32.97),
(2, '2023-02-02', 18.99),
(3, '2023-02-03', 25.98),
(4, '2023-02-04', 29.97),
(5, '2023-02-05', 14.99);
INSERT INTO Inventory (BookID, stock)
VALUES
(1, 50),
(2, 30),
(3, 20),
(4, 40),
(5, 60);
To embed this program on your website, copy the following code and paste it into your website's HTML: