-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgym.sql
More file actions
85 lines (74 loc) · 2.64 KB
/
gym.sql
File metadata and controls
85 lines (74 loc) · 2.64 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
CREATE TABLE members (
id BIGSERIAL PRIMARY KEY,
full_name VARCHAR(120) NOT NULL,
gender VARCHAR(10),
phone VARCHAR(20) UNIQUE,
email VARCHAR(100) UNIQUE,
date_of_birth DATE,
join_date DATE DEFAULT CURRENT_DATE,
status VARCHAR(20) DEFAULT 'active'
);
CREATE TABLE trainers (
id BIGSERIAL PRIMARY KEY,
full_name VARCHAR(120) NOT NULL,
specialty VARCHAR(120),
phone VARCHAR(20),
hired_at DATE DEFAULT CURRENT_DATE
);
CREATE TABLE plans (
id BIGSERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL, -- e.g., Monthly, 3-Month VIP
duration_days INT NOT NULL,
price DECIMAL(10,2) NOT NULL
);
CREATE TABLE subscriptions (
id BIGSERIAL PRIMARY KEY,
member_id BIGINT REFERENCES members(id),
plan_id BIGINT REFERENCES plans(id),
start_date DATE NOT NULL,
end_date DATE NOT NULL,
status VARCHAR(20) DEFAULT 'active'
);
CREATE TABLE payments (
id BIGSERIAL PRIMARY KEY,
member_id BIGINT REFERENCES members(id),
subscription_id BIGINT REFERENCES subscriptions(id),
amount DECIMAL(10,2) NOT NULL,
method VARCHAR(50), -- Cash, ABA, Wing, Credit Card
paid_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE classes (
id BIGSERIAL PRIMARY KEY,
name VARCHAR(120) NOT NULL, -- e.g., Yoga, Muay Thai, Cardio Fit
description TEXT
);
CREATE TABLE class_schedules (
id BIGSERIAL PRIMARY KEY,
class_id BIGINT REFERENCES classes(id),
trainer_id BIGINT REFERENCES trainers(id),
start_time TIMESTAMP NOT NULL,
end_time TIMESTAMP NOT NULL,
room VARCHAR(60)
);
CREATE TABLE class_attendance (
id BIGSERIAL PRIMARY KEY,
schedule_id BIGINT REFERENCES class_schedules(id),
member_id BIGINT REFERENCES members(id),
check_in_time TIMESTAMP DEFAULT NOW()
);
CREATE TABLE checkins (
id BIGSERIAL PRIMARY KEY,
member_id BIGINT REFERENCES members(id),
check_in_time TIMESTAMP DEFAULT NOW()
);
-- | Table | Purpose |
-- | ------------------ | ---------------------------------------- |
-- | `members` | Gym member/customer information |
-- | `trainers` | Personal trainers/instructors |
-- | `plans` | Membership plans (monthly, yearly, VIP…) |
-- | `subscriptions` | Which plan a member is currently on |
-- | `classes` | Group class types (Yoga, Boxing, Zumba…) |
-- | `class_schedules` | Timetable for each class |
-- | `class_attendance` | Which members attended which sessions |
-- | `payments` | Payments for subscriptions |
-- | `checkins` | Track member gym entry (QR/ID card scan) |