I am just learning mySQL and PHP. Needless to say, I am a noob and this is I'm sure a very rudimentary question. I would do a little more research, but I don't really even know how to ask the question (I told you I was new :))
So, my first database driven site that I am trying to build is a sleep logger. The functionality is very simple: onclick of the "asleep" button LOCALTIMESTAMP is submitted to mySQL in a table that has ID, DATETIME, and USERID as it's columns. The same functionality is triggered for the "awake" function and is stored in a different table.
The challenge: I would like to JOIN the asleep record with the awake record as one "sleep session" to be displayed as a list on the website. I can do a basic join on ID of these 2 tables, but the obv isn't good design and doesn't support multiple users. I am sure at some point the IDs of asleep and awake would not match properly. I thought about using DATETIME, USER and ID, but could still run into problems if the user had several sleep sessions in a single day.
So, I told you, pretty basic, but I am stuck. A solution or a nudge in the right direction would be much appreciated!