0% found this document useful (0 votes)
6 views

MySQL DATABASE

The document contains SQL code for creating a database named 'RestaurantDB' along with several tables including Menu, Orders, OrderDetails, Inventory, Customers, Employees, and Reservations. Each table is designed to manage different aspects of a restaurant's operations such as menu items, orders, inventory, and customer reservations. The code also includes foreign key constraints to maintain data integrity between related tables.

Uploaded by

Dilshad Alam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

MySQL DATABASE

The document contains SQL code for creating a database named 'RestaurantDB' along with several tables including Menu, Orders, OrderDetails, Inventory, Customers, Employees, and Reservations. Each table is designed to manage different aspects of a restaurant's operations such as menu items, orders, inventory, and customer reservations. The code also includes foreign key constraints to maintain data integrity between related tables.

Uploaded by

Dilshad Alam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

My SQL code

-- Create the database

CREATE DATABASE RestaurantDB;

-- Use the created database

USE RestaurantDB;

-- Table for menu items

CREATE TABLE Menu (

item_id INT AUTO_INCREMENT PRIMARY KEY,

item_name VARCHAR(100) NOT NULL,

price DECIMAL(10, 2) NOT NULL,

category VARCHAR(50) NOT NULL

);

-- Table for orders

CREATE TABLE Orders (

order_id INT AUTO_INCREMENT PRIMARY KEY,

table_number INT NOT NULL,


order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

-- Table for order details

CREATE TABLE OrderDetails (

detail_id INT AUTO_INCREMENT PRIMARY KEY,

order_id INT NOT NULL,

item_id INT NOT NULL,

quantity INT NOT NULL,

FOREIGN KEY (order_id) REFERENCES Orders(order_id) ON


DELETE CASCADE,

FOREIGN KEY (item_id) REFERENCES Menu(item_id) ON


DELETE CASCADE

);

-- Table for inventory

CREATE TABLE Inventory (

item_id INT PRIMARY KEY,

stock INT NOT NULL,

FOREIGN KEY (item_id) REFERENCES Menu(item_id) ON


DELETE CASCADE

);
-- Table for customers

CREATE TABLE Customers (

customer_id INT AUTO_INCREMENT PRIMARY KEY,

customer_name VARCHAR(100) NOT NULL,

customer_phone VARCHAR(15) NOT NULL

);

-- Table for employees

CREATE TABLE Employees (

employee_id INT AUTO_INCREMENT PRIMARY KEY,

employee_name VARCHAR(100) NOT NULL,

employee_position VARCHAR(50) NOT NULL,

salary DECIMAL(10, 2) NOT NULL

);

-- Table for reservations

CREATE TABLE Reservations (

reservation_id INT AUTO_INCREMENT PRIMARY KEY,

customer_id INT NOT NULL,

reservation_date DATETIME NOT NULL,


table_number INT NOT NULL,

number_of_people INT NOT NULL,

FOREIGN KEY (customer_id) REFERENCES


Customers(customer_id) ON DELETE CASCADE

);

Group members

Dilshad Alam
Rishi Verma
Shivam Prakash

You might also like