I have a composite/bridge entity between two different entities:
CARDS:
CARD_ID; [Primary Key]
// Other attributes
BRIDGE_ENTITY:
CARD_ID; [Primary & Foreign Key]
MACHINE_ID; [Primary & Foreign Key]
// Other attributes
MACHINES:
MACHINE_ID; [Primary Key]
// Other attributes
Any card registered in the system can be used to access many machines, and vice versa. This is a common many-to-many relationship.
I understand that composite keys cannot have repeating values. But, there is a possibility in my database design that the composite keys in the database design will have different values that repeat multiple times. How do I modify the attributes in such a way that both CARD_ID and MACHINE_ID can have the same or different values across multiple rows without causing a problem? Would adding a new primary key towards the bridge entity called LOG_ID (unique ID) be possible?
bridgetable is permitted to have multiple rows with the samecard_idand multiple rows with the samemachine_id. What it can't have is multiple rows with the same(card_id, machine_id)combination. Now are you saying you want to have multiple rows with the same(card_id, machine_id)? - karmakazeCARD_IDand oneMACHINE_ID? Whatever that reason is, you can put in a third column of thebridgetable and also make it part of the primary key so that you can have (CARD_ID, MACHINE_ID, reason) which is unique. - karmakaze