Null Bridge FKs?

What is the purpose of a bridge table? It is used to represent a M:N relationship.

What is a M:N relationship? Brothers and sisters. Students and classes. Customers and products. If a record in table X can be related to multiple records in table Y, and a record in table Y can be related to multiple records in table X, then we need to create an XY bridge table to represent the relationship.

The bridge table represents the actual combinations of records from the two tables. If two brothers (Adam and Ben) have three sisters (Carla, Denise, Elizabeth), then there are six brother-sister records in the bridge:

1   Adam  Carla
2AdamDenise
3AdamElizabeth
4BenCarla
5BenDenise
6BenElizabeth

Notice that we would never put a "half record" in the bridge. We would never have a record with a blank girl or a blank boy. Those records just wouldn't make any sense. Right?

7   Adam  _____
8_____Elizabeth

The names of the boys and girls in this little example are the foreign keys that point to the tables of boy and girl data (e.g., full names, DOBs, favorite foods). Of course, names aren't unique, so we'd probably use keys like B1001 and B1002 for Adam and Ben and keys like G1001, G1002 and G1003 for Carla, Denise and Elizabeth. The revised bridge table would be:

PK   BID (fk1)  GID (fk2)
1B1001G1001
2B1001G1002
3B1001G1003
4B1002G1001
5B1002G1002
6B1002G1003

Again, we would never put a "half record" in the bridge.

Bottom Line: The foreign key fields in a bridge table should be non-blank.

More FAQs