I am having a discussion with someone about the following table that is used to link client-specific items:
Table LINK:
Client (int)
Item1 (int)
Item2 (int)
This is the disputed design. All three fields refer to other tables. The two Item fields refer to the same other table. These are not real field names, so don't bother with discussing naming conventions (the "1" and "2" are, however, really part of the field name). I am arguing that this design is bad on 1NF-violation grounds, while the other person is arguing that even though this seems distasteful, all other options are worse for our specific use-case.
Notes:
- The vast majority of cases will only require linking two items with each other;
- N:1 groups are however allowed; in such a case, the same Item1 is repeated on multiple lines with different Item2 values;
- There are also a very small number of cases where some Item2 values (in an existing Item1-Item2 links) are themselves linked to other Items, and in these cases these values occur in the Item1 column, with the other linked value in the Item2 column; all linked items correspond to one group, and must be retrieved as such.
My claims:
- This violates 1NF: Item1 and Item2 are foreign keys for the same table, and as such constitute a repeating group (the other party disagrees on the defn of repeating group);
- For searches on Item, this means that two indexes are required instead of one, for example in a table that uses a GroupID field instead;
- This makes queries looking for a specific Item in this table more complex, because a restriction clause must examine both Item1 and Item2 fields.
- The retrieval for the case where chains of Item links occur will be more complex.
The other side claims:
- The most viable alternative is a table with a single Item field, and an additional GroupID field;
- The simpler, more common two-item link case now becomes more complex;
- There could be concurrency issues in obtaining GroupID slots, and that needs to be managed
- Managing the GroupID concurrency issues probably requires a second table with GroupIDs in a field with a uniqueness constraint
- You now have to perform a join, at least some of the time, especially if an ORM is used. The join is less efficient than using a single table as in current design.
I would like to hear some opinions about this. I have read the other posts on SO about database design, and especially 1NF, but they don't deal as specifically with my case above as I would have liked. I have also come to understand, based on much research online, that so-called standards like 1NF can be defined in many different ways by different people. I have tried to be as clear as possible about both arguments, and not to bias one or the other.
EDIT 1:
- Item1 and Item2 are (financial) transactions
- The "1" and "2" are really part of the field name