mysql - Could be duplicate records in many-to-many table? -
i have table person, room , person_room.
when person entry room i'm creating new record in person_room.
but when person leaves room should i:
- delete record in person_room ?
- create new record bool information person gone?
tables:
------------------ 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 bool, 1 - person entered, 0 - person walks away)
example of 2)
when person 1 (peter) entry room 1 (kitchen)
--------------------------------------------- person_room ------------------------------------------------ id | room_id | person_id | status | created | ------------------------------------------------ 1 | 4 | 7 | 1 | 2016-02-05 | ------------------------------------------------
then person 1 (peter) leaves room 1 (kitchen)
--------------------------------------------- person_room ------------------------------------------------ id | room_id | person_id | status | created | ------------------------------------------------ 1 | 4 | 7 | 1 | 2016-02-05 | 2 | 4 | 7 | 0 | 2016-02-06 | ------------------------------------------------
it solution tracking is/was where, how long, entry counting etc..?
Comments
Post a Comment