My problem:
- On a
PHP/MySQLapplication I have to distinguish theregistered accountsfrom thesimple visitors. Both of them can perform actions which are written into the database. Now I use a separate table forvisitorsand a separate table forregistered accounts.
My example solutions so far:
Option #1:
Registered accountsandvisitorsare separated into two tables. Both of them can havesessionsand the relationship between the tables arenon-mandatory, since a person is either avisitoror aregistered account.
Option #2: Everyone is in one table and the relationship between the tables are mandatory, since everyone can have
sessions, but since a person is either avisitoror aregistered account, he might not have anemailorpassword, so that can be NULL. This might lead to errors in the integrity.

My question:
- Should I keep the
accountsin a separate table from thevisitorsor I can put everyone in one table with a BOOLEANisThisAccountvariable that indicates whenever the person is aregistered accountor just a simplevisitor?
I also am open to different approaches.
I would probably go with a third option: Link sessions to visitors and visitors to accounts. That way you need only one field
visitorIDin thesessionstable and only oneNULLcolumn (accountIDinvisitors). In my opinion that's conceptually cleaner, since people performing actions are always visitors, who may or may not have an account.