I am wondering how someone experienced in the field of databases would structure the information in this table(matrix) in a DB?
https://bit.ly/2PPlqE3
PS: I am currently learning some SQL. Any ideas and opinions more than welcome.
If you just need to display this information, and you don't need your users to be able to change the data, I'd strongly consider not putting it in a database. It's a small amount of data that could easily be kept in memory. You could either hard-code it directly in your programming language, or load it once from a file (I'd probably format it as JSON, but there are many options) when your app/server starts. This would be faster and have fewer moving parts than loading it from a database as needed.
If you do need a database, I can see cases where either of the proposed schemas could have advantages.
I totally agree that a JSON can do the job. I also thought about AirTable or GoogleSheet but currently I want to explore a little bit the databases so even if it's not 100% necessary I will stick to this approach :) Ty for your comment.
I'm not an expert in databases by any means. In my experience, DB design is VERY dependent on your use case. Questions you might want to ask yourself:
If I were in your shoes, here's what I'd do:
The table will have 12 columns:
Couple of things to watch out:
Why I picked this design:
SELECT (first_zodiac, second_zodiac) FROM table WHERE percentage_value > 0.5 AND harmonious == t;Hope this helps!
This is a good solution!
And if you make a query to the table through the frontend,
where the order of entering the two search fields is not fixed, you can use:
SELECT * FROM TABLE WHERE (FIRST_ZODIAC=:PARAM1 AND SECOND_ZODIAC=:PARAM2) OR (FIRST_ZODIAC=:PARAM2 AND SECOND_ZODIAC=:PARAM1)Thank you, Albert. This definitely help me a lot.
The business will be very simple:
2 Drop downs containing all the zodiac signs.
The user chooses his/her sign and the one to be matched and I just output that compatibility info.
Thx again for your detailed answer.
Zodiac can probably just be an ENum since you have a constant non changing and short list
Relationship table
Zodiac1
Zodiac2
(Primary key is both together)
The rest of you metadata
%match
8bollean fields for the described properties of they are constant
If that's your entire table you probably don't need a db, just a json file or similar
Using the following format:
I'd propose the following structure:
Example table rows:
This looks a little bit more complex and implies more tables but I like it.
I will keep in mind your example.
Thx for the answer :)