My site enables communication between both registered and non-registered users. I’m trying to determine the best practice for storing non-registered users in the database. My initial schema was as follows:
Users
------------
user_id
device_id *Unique* (this is for mobile app users)
email *Unique*
phone *Unique*
first_name
last_name
image_url
date_joined
UserNames (Users have custom names for each group potentially)
-------------
name_id
user_id
group_id
first_name
last_name
Further details of how the app works:
- Users register and create groups/lists which include both registered and non-registered users
- Messages are then sent to members of the groups/lists
- Note: registered users can add non-registered users to lists without their explicit approval.
I chose the design listed above because emails, phone numbers, and device IDs would be unique. However users may have different names/nick names for each of the users, hence the UserNames table. However it’s not clear to me whether or not storing non-registered users should be stored in the Users table given that they aren’t technically registered users of the site.
Should I be storing the non-registered/external users in a separate table? Let me know if you need me to clarify anything.
Whether you segregate unregistered user into their own table is a design decision probably only you can answer. It would probably depend on how these different user types are used throughout your application. It could be something as simple as having a tinyint field with 0 or 1 values to indicate a user is registered.