-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
40 lines (36 loc) · 950 Bytes
/
schema.sql
File metadata and controls
40 lines (36 loc) · 950 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
32
33
34
35
36
37
38
39
40
-- Group Buys Database Schema
-- Creates tables for managing group buying campaigns
-- Users table
CREATE TABLE users (
user_id INT PRIMARY KEY,
username VARCHAR(50),
email VARCHAR(100),
join_date DATE
);
-- Products table
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(100),
regular_price DECIMAL(10,2),
category VARCHAR(50)
);
-- Group Buys table
CREATE TABLE group_buys (
group_buy_id INT PRIMARY KEY,
product_id INT,
group_price DECIMAL(10,2),
minimum_participants INT,
start_date DATE,
end_date DATE,
status VARCHAR(20),
FOREIGN KEY (product_id) REFERENCES products(product_id)
);
-- Participants table
CREATE TABLE participants (
participant_id INT PRIMARY KEY,
group_buy_id INT,
user_id INT,
joined_date DATE,
FOREIGN KEY (group_buy_id) REFERENCES group_buys(group_buy_id),
FOREIGN KEY (user_id) REFERENCES users(user_id)
);