Francesco
Francesco

Reputation: 25269

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?

Upvotes: 0

Views: 76

Answers (1)

Andrea Stringham
Andrea Stringham

Reputation: 44

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.

Upvotes: 1

Related Questions