-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (24 loc) · 840 Bytes
/
Copy pathschema.sql
File metadata and controls
31 lines (24 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
CREATE DATABASE IF NOT EXISTS restaurant_system;
USE restaurant_system;
-- Orders Table -- One row per receipt
-- Order Items Table-- Multiple rows per receipt
CREATE TABLE IF NOT EXISTS orders(
order_id int auto_increment primary key,
order_time timestamp default current_timestamp,
subtotal decimal(10,2) not null,
tax decimal(10,2) not null,
tip decimal(10,2) not null,
total decimal(10,2) not null,
signature varchar(50)
);
ALTERTABLE orders AUTO_INCREMENT = 200;
CREATE TABLE IF NOT EXISTS order_items(
item_id int auto_increment primary key,
order_id int not null,
item_name varchar(100) not null,
quantity int not null,
price decimal(10,2) not null,
FOREIGN KEY (order_id)
REFERENCES orders(order_id)
ON DELETE CASCADE
)