简体   繁体   中英

What is the best practice to store users on mysql?

I'm storing job profiles in my db kinda like Linkedin does. you can sign up as a candidate or as a company but now i have only one table

user_tb

where user_tb.user_type is the tag to identify a candidate user vs a member/visitor, vs. a company

Imagine if i wanted the users to be able to add their own employees of that company.

where the employees should be stored? I'd store them in the main user_tb right? so what about companies? and if i store employees in the same user_tb their email cannot be empty... how can i fill emails if i don't have them?

shoudl be user_tb a separate table from employees?

I would create a separate table for companies and users, and then have a column on the users table for their company id to link them together. It gets too messy when you try to cram everything together into one table.

If the users table requires an email, and you're wanting a place for companies to add employees, you can require them to give the employees email, or create a separate table for employees that doesn't require an email, but can be checked before signing up a new user to see if they already exist in the "employees" table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM