Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following information from two tables (Categories and Subcategories)

enter image description here

Note that in the Subcategories table, Subcategory 1 is repeated in two Categories; in Category A and Category B. My question is, when it comes to relating the two tables, and recording the data in the DB, what is the best way to do it?

At first, I considered relating the two tables directly, with a foreign key in the Subcategories table, and registering the subcategory that is repeated in the DB but in JSON format, like this:

enter image description here

But then I thought about having a detailed table in between, which would allow me to relate the two tables ... The point is that since there is only one subcategory that is repeated (subcategory 1), I don't know if it merits and is worth one detail table to relate the Categories and Subcategories tables; and I also don't know if storing IDs of another entity in JSON format is the best option ...

How can I do it better?

Thank you very much for any help and suggestions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...