-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.dbml
More file actions
168 lines (147 loc) · 3.9 KB
/
schema.dbml
File metadata and controls
168 lines (147 loc) · 3.9 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// A group registered with the service
Table groups {
id int [pk]
name varchar [unique]
active boolean [default: true]
paid_through date [null]
created_utc datetime [default: 'now()']
}
Table payment_types {
id int [pk]
group_id int [ref: > groups.id]
stripe_token varchar
created_utc datetime [default: 'now()']
}
Table payments {
id int [pk]
payment_type_id int [ref: > payment_types.id]
amount int
created_utc datetime [default: 'now()']
}
// Enumerate possible roles here: admin, player, etc
Table roles {
id int [pk]
name varchar
}
// A user of the service
Table users {
id int [pk]
role_id int [ref: > roles.id]
group_id int [ref: > groups.id]
email varchar
display_name varchar [null]
password varchar
active boolean [default: true]
created_utc datetime [default: 'now()']
}
// Buy-ins and cash-outs
Table transactions {
id int [pk]
user_id int [ref: > users.id]
amount int
created_utc datetime [default: 'now()']
}
// ========= END ADMIN DATA | BEGIN POKER DATA =========
Table tables {
id int [pk]
group_id int [ref: > groups.id]
name varchar // Currently a random string, remove?
seats int [note: "number of seats, max players allowed"]
created_utc datetime [default: 'now()']
}
// Persistent in-game player data. The player's session.
Table players {
id int [pk]
user_id int [ref: > users.id]
table_id int [ref: > tables.id]
stack int [default: 0] // Amount of money available to bet
sitting_out boolean [default: false]
seat int
created_utc datetime [default: 'now()']
}
// Mark user as having an active play session
Table players_active {
id int [pk]
user_id int [ref: > users.id, unique]
player_id int [ref: > players.id]
}
// TODO - Should this live in DB or in server code?
Enum states {
OPEN
CLOSED
VOID
}
Table hands {
id int [pk]
table_id int [ref: > tables.id]
dealer_id int [ref: > players.id]
next_id int [ref: > players.id]
rounds int [note: "Number of betting rounds per hand (e.g. 4 for NLHE: preflop, flop, turn river)"]
state states
created_utc datetime [default: 'now()']
}
Table hands_active {
id int [pk]
table_id int [ref: > tables.id]
hand_id int [ref: > hands.id]
}
// TODO - Need some way to represent a stack of pots to be resolved
Table pots {
id int [pk]
hand_id int [ref: > hands.id]
amount int
created_utc datetime [default: 'now()']
}
Table betting_rounds {
id int [pk]
hand_id int [ref: > hands.id]
round_num int
name varchar [note: "e.g. preflop, flop, turn, etc"] // Might not need this
bet int [note: "The highest current bet for the round. The amount that must be matched."]
bettor int [ref: > players.id, note: "The player who played the lead bet"]
state states
created_utc datetime [default: 'now()']
}
Table betting_rounds_active {
id int [pk]
betting_round_id int [ref: > betting_rounds.id]
hand_id int [ref: > hands.id]
}
Table bets {
id int [pk]
player_id int [ref: > players.id]
betting_round_id int [ref: > betting_rounds.id]
amount int
created_utc datetime [default: 'now()']
}
Table holdings {
id int [pk]
player_id int [ref: > players.id, null]
hand_id int [ref: > hands.id]
is_board boolean [default: False] // Must be true if player_id is False
active boolean [default: True] // Set to False if hand folded
created_utc datetime [default: 'now()']
}
// Enumerate all cards
Table cards {
id int [pk]
code int // The deuces code for this card
}
// M2M relationship table, shows which cards a player had
Table holdings_to_cards {
holdings_id int [pk, ref: > holdings.id]
cards_id int [pk, ref: > cards.id]
exposed boolean [default: False] // Set true for face-up cards
}
Enum action_types {
BLIND
FOLD
CHECK
BET
}
Table actions {
id int [pk]
holding_id int [ref: > holdings.id] // Blind actions occur before player sees cards, but holdings record will already exist
type action_types
created_utc datetime [default: 'now()']
}