How to determine the type of data to use in this flexible case?

0

The project consists of a database for RPG tokens (D & D and similar). It looks like this:

  

Database
  tab

     

Tables

     
  • character
  •   
  • system
  •   
  • raca
  •   
  • class
  •   
  • attribute
  •   
  • character_atribution
  •   

Relationships

     
  • CHARACTER = N ======== 1 = SYSTEM
  •   
  • CHARACTER = N ======== 1 = RACE
  •   
  • CHARACTER = N ======== 1 = CLASS
  •   
  • CHARACTER = N ======== N = ATTRIBUTE == CHARACTER_ATRIBUTE
  •   

In the "attribute" table there are attributes that can contain texts (ex: Background), numbers (ex: Strength points = 15), texts and numbers (ex: Arc, 2D6 distance damage, 1D6 melee damage) .

How do I create this in the personagem_atributo table?

I thought of creating a column (attribute) with the name valor with type varchar , but this way I get stuck to just type varchar . How can I assign a type to the value according to the information given ( int , text , varchar )?

    
asked by anonymous 16.11.2018 / 23:23

1 answer

0

There is no problem in doing this in a relational database. It may possibly not be the most appropriate, but if you leave the relational and almost all the rest you need the relational then you get into bigger problem yet. It is better to have the ideal mostly and the less ideal in the rest, but that is correct too.

You will work with key and value. There are several ways to do this. But you'll have to deal with it manually, but almost always not very different from what you'd have to do in a NoSQL , after all it it does not make a miracle, it frees you from schema , but not from having to deal with things you do not even know what it is.

In some cases you can make it simpler, but I think you want to use the EAV standard . Of course the identifiers can be enumerations, or even strings , but it is much worse and costs a lot more, usually unnecessarily, as NoSQL does. I think it's even ideal that% column% is used and in an auxiliary table of available columns you have indicated what type it is to give more information than you need. This is much more efficient than the model used in NoSQL.

Actually almost always the model NoSchema of the NoSQL (wrong name of the technology) and the adopted EAV is wrong and it would be better to do a relational. There are few cases where the lack of schema really is a good solution, even if it gives more work to do with schema .     

18.11.2018 / 14:10