locked
how to handle multi-choice value field in DBMS RRS feed

  • Question

  • User-1094550701 posted

    Hi, 

    i am confused about this question:

    if we have a database table e.g. CASE and there is a field in it called Status and status will have a list of status like new, open, close, solved etc.

    my question is should i make another table for status or i can hard code this? what is standard of DBMS

    Thursday, April 18, 2013 4:14 PM

Answers

  • User1508394307 posted

    It's all up to you. If case could have only one status then you can have status code saved in Case table, but name of the status could be separately stored in a dedicated table

    Case
    -----------------
    ID       Status
    1 ...... N
    2 ...... N
    3 ...... O
    
    Status
    -----------------
    Status   StatusName
    N        New
    O        Open
    C        Closed
    S        Solved

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 18, 2013 5:00 PM

All replies

  • User1508394307 posted

    It's all up to you. If case could have only one status then you can have status code saved in Case table, but name of the status could be separately stored in a dedicated table

    Case
    -----------------
    ID       Status
    1 ...... N
    2 ...... N
    3 ...... O
    
    Status
    -----------------
    Status   StatusName
    N        New
    O        Open
    C        Closed
    S        Solved

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 18, 2013 5:00 PM
  • User-1094550701 posted

    I did the same now, but i did not create a forigen key relation between them. i think it doesn't matter?

    Thursday, April 18, 2013 5:12 PM
  • User1508394307 posted

    Again, it's up to you but if you want to follow the best practice, then foreign key is a must. It helps enforce referential integrity (can't insert cases with unknown status, can't delete status if case with such status exists), it helps to execute queries faster.

    Thursday, April 18, 2013 5:27 PM