How to care for status in a part of the system?

0

One question I have is how to take care of the status of a part of the system.

So, I'll give you an example, I have a question table and an answer table for that question.

In these tables I have date field (question: dt_time and answer: dt_reset)

I need to know when a question is:

  • unsuccessful
  • open
  • answered

But for this it would be even simple, just check the dates, whether or not it was answered and make the comparisons.

But then I get into the problem:

He thinks that for a given customer, he does not want the term "open" but rather "in process," and so on, to even want to determine a color for that different status, that per customer.

Could I explain my problem?

I thought of such tables

PERGUNTA
id
texto
dt_pergunta
cliente_id

RESPOSTA
id
pergunta_id
resposta
dt_resposta

STATUS
id
cliente_id
termo
cor

But how to know which status is which?!

    
asked by anonymous 01.02.2017 / 18:04

1 answer

2

A review (after all, there are unclear things in the question):

  • Your current table configuration contains a table named PERGUNTA , which stores the question data and contains a foreign key for the client that made it (or that holds it - the problem domain is unclear in the question).

  • It also contains a table called RESPOSTA , which contains the data of the various (0 .. m) possible answers to a question. Since it does not have a cliente_id field, it is assumed that all answers belong to the question client.

  • And it also contains a table called STATUS , which although called this way has nothing to do with the state of the question. Rather, what it stores are customer preferences. You call termo the label of the question state, and you call cor the color in which that state will be displayed.

Well, for you to relate customer preference to different possible states, you first need to define the possible statuses . That is, you can infer via programming that a question is "open" because it has no answers, but it is impossible to relate this in the preferences if that situation does not have an identifier that represents it.

The best thing, in my opinion, would be for you to have a field in the PERGUNTA table, that sim called status , for example, representing the current query state from a list of unique and mutually exclusive values ( may be integers 0, 1, 2, 3, ..., etc., provided that each represents a single state). Then you model your preference table (which, by the way, I suggest you have that name!). As you have more than one state, you will need to have a n x m relationship of preferences for each state's preferences. So it's more or less something like:

PERGUNTA
...
id_estado

ESTADOS
id

PREFERENCIAS
id
cliente_id

PREFERENCIAS_ESTADOS
id
id_preferencia
id_estado
termo
cor
    
01.02.2017 / 19:09