Deepak velu
Deepak velu

Reputation: 154

Getting a entry for one table using the other columns in another table

I'm kind of struggling with my DB design. Please refer this image for clear understanding.
enter image description here

In the tbo_current_status table, there is an active_status field and I want to fill it with any one the fields in tbo_status (status_type_1,status_type_2...etc). How can I do that?

If you have any different ideas feel free to share them :)

Upvotes: 0

Views: 68

Answers (1)

erastl
erastl

Reputation: 411

I think it may be easier to have tbo_status be [Project ID], [Status Type Number], and [Status Display Name] fields, and then have each status be a record. Then you can use the Status Type Number as the foreign key in tbo_current_status. It doesn't explicitly enforce that there are 5 statuses, the way you did by making them columns, but it's easier to reference them in the way you're trying to use them.

If you want to enforce 5 statuses, maybe you make another table, tbo_status_type_list, that defines the 5 numbers, and make that a foreign key for Status Type Number in your tbo_status table.

Upvotes: 1

Related Questions