-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQL_TABLES.txt
65 lines (49 loc) · 2.02 KB
/
SQL_TABLES.txt
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
TABLE: GlobalChatHistory
========================
+-------+-----------+-----------+-----------+-----------+---------------+
| id | content | type | author | room | timestamp |
+-------+-----------+-----------+-----------+-----------+---------------+
One row constitutes a single message sent to a single room by a single user
id = primary key
content = string of variable length (no limits)
type = string("text"||"drawing")
author = id (==> User)
room = id (==> Room)
timestamp = date&time
TABLE: UserChatHistory
======================
+-------+-----------+-----------+---------------+---------------+
| id | user | room | join_time | end_time |
+-------+-----------+-----------+---------------+---------------+
One row represents the time the user was active in a given room
id = primary key
user = id (==> User)
room = id (==> Room)
join_time = date&time when user joined the room
end_time = date&time when user left the room
TABLE: User
===========
+-------+-----------+---------------+-------------------+
| id | name | join_date | last_visited |
+-------+-----------+---------------+-------------------+
One row represents a single user registered with the site
id = primary key
name = string
join_date = date&time when user "registered" with the site
last_visited = date&time of last visit
TABLE: Room
===========
+-------+-----------+-----------+-----------+
| id | title | created | expired |
+-------+-----------+-----------+-----------+
One row represents a single room which was created sometime in the past
id = primary key
title = string (Custom Room title if need be. Can be null)
created = date&time when room was created
expired = date&time when room expired (can be null for currently active rooms)
Remarks
-------
I hope you already know what a primary key is.
(==>) denotes that the field points to the primary key of another table (foreign key)
date&time simply denotes that you should use the time/date datatype in SQL
string = varchar (with a sensible limit) or text, your choice BUT content in GlobalChatHistory should be TEXT