Combine two tables or keep them separate?
Structure
TableA (each row in TableA can map to one or more row in circle)
Id
Name
TableB (each row in TableB can map to only one row in TableA)
Id
TableAId
UniqueValue
开发者_如何学GoExample Data
TableA
1,Sooprise
TableB
1,1,something
2,1,somethingElse
So in this case, "UniqueValue" can only associate themselves to one row in TableA. Would it make more sense to combine the tables?
Structure
TableC
Id
Name
UniqueValue
Example Data
TableC
1,Sooprise,something
2,Sooprise,somethingElse
I'm leaning more towards the first choice, but since there is a one to one mapping from B to A, these tables can be combined. I do understand that combining the tables would result in a data redundancy (Name) but maybe there can be exceptions made for not using two relational tables?
I'd keep the two tables separated. And I would create a view to get the next structure if needed.
I think the choice will be determined by what the tables are going to be used for. Two tables are probably the better design if you look at database space (Which may not be a concern), and if you are concerned about updated. (if 1,Sooprise becomes 1,Sooprise_New do you want to update all of the records in table B, or do you want the values to remain 1,Sooprise for some entries)?
I have found that for future changes in data structures its best to keep twp tables
It depends. What are the tables used for? If you find yourself needing data from multiple relational tables at the same time, then it's probably a good idea to join them. If their use is largely separate and you feel separate tables enhance clarity, then keep them separate.
精彩评论