1

I'm modelling DB and wondering if I should create more very simple tables or just have more columns in tables.

I mean, let's assume I have s table named User, each user can have status(ACTIVE, INACTIVE, BLOCKED, ...). Should I store status directly in User(as an ENUM?) table or maybe it's better to create a table named UserStatus with status ID, status name and FK pointing to the user?

Similar with employees and their position(manager, developer, etc.).

Can you give me some advices?

1

Typically user would have the fk

user:
ID (pk)
Name
StatusID (fk referencing status.ID)

status:
ID (pk)
Name

A user has a status - not a status has a user

1

On relations which are one to one (one User has one Status) it often is better to add a column to your table. If it is more complex or you want to make your Software prepared for future requests, make a table. For example could it be possible that one employee could have several positions. This would be a one to multiple relation. In this case you would store that data in an extra table. There is not a wrong or right. You always have to check your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.