forked from AngelShynk/practicalAssignment02Helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_01_create_tables.sql
More file actions
28 lines (25 loc) · 868 Bytes
/
script_01_create_tables.sql
File metadata and controls
28 lines (25 loc) · 868 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
CREATE DATABASE IF NOT EXISTS opt_db;
USE opt_db;
CREATE TABLE IF NOT EXISTS opt_clients (
id CHAR(36) PRIMARY KEY,
name VARCHAR(255) NOT NULL,
surname VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phone VARCHAR(50) NOT NULL,
address TEXT NOT NULL,
status ENUM('active', 'inactive') NOT NULL
);
CREATE TABLE IF NOT EXISTS opt_products (
product_id INT AUTO_INCREMENT PRIMARY KEY,
product_name VARCHAR(255) NOT NULL,
product_category ENUM('Category1', 'Category2', 'Category3', 'Category4', 'Category5') NOT NULL,
description TEXT
);
CREATE TABLE IF NOT EXISTS opt_orders (
order_id INT AUTO_INCREMENT PRIMARY KEY,
order_date DATE NOT NULL,
client_id CHAR(36),
product_id INT,
FOREIGN KEY (client_id) REFERENCES opt_clients(id),
FOREIGN KEY (product_id) REFERENCES opt_products(product_id)
);