我有桌子,房间和人物室。
当人进入房间时,我会在person_room中创建新记录。
但当我离开房间时,我应该:
表:
------------------
ROOM
------------------
ID | Description |
------------------
...
4 | Kitchen
5 | Living room
...
------------------
------------------
PERSON
------------------
ID | Description |
------------------
...
7 | Peter
8 | John
...
------------------
---------------------------------------------
PERSON_ROOM
---------------------------------------------
ID | ROOM_ID | PERSON_ID | STATUS | CREATED |
---------------------------------------------
...
---------------------------------------------
(Column status is bool, 1 - person entered, 0 - person walks away)
2)的例子
当人1(彼得)进入房间1(厨房)时
---------------------------------------------
PERSON_ROOM
------------------------------------------------
ID | ROOM_ID | PERSON_ID | STATUS | CREATED |
------------------------------------------------
1 | 4 | 7 | 1 | 2016-02-05 |
------------------------------------------------
然后第1个人(彼得)离开房间1(厨房)
---------------------------------------------
PERSON_ROOM
------------------------------------------------
ID | ROOM_ID | PERSON_ID | STATUS | CREATED |
------------------------------------------------
1 | 4 | 7 | 1 | 2016-02-05 |
2 | 4 | 7 | 0 | 2016-02-06 |
------------------------------------------------
这是一个很好的解决方案,可以跟踪谁在哪里,在多长时间,有多少时间,计入等等。?