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:

  1. delete record in person_room ?
  2. 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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -