Reputation: 83
I am thinking about making a composite key for a table of mine (which would be composed of two fields, fields A and B). However, field B is dependent on field A. Would this composite key violate any database design principles?
Upvotes: 0
Views: 624
Reputation: 1270653
Well, yes. It does violate database design principles. Why not just use A
? That is, you can always look up the value of B
using a JOIN
, so a composite foreign key reference is unnecessary. Storing the value of B
in referring tables is redundant and inefficient (takes up space in both data pages and index pages).
There are some cases where such a foreign key is useful. You have not provided enough information to know if you have such a case. So, as a general design principle this doesn't sound right. There may be exceptions, so it is not always a bad idea.
Upvotes: 2