I've run across something that's bugging me just enough that I wanted to come here and seek out a sort of "best practice" type of advice from you guys (et gals)
I have a table in my model, let's call it prospect
. Two separate external systems can provide an update for rows in this table, but only as a "status" of that record in those respective systems.
I need to store those statuses locally. Initial idea, of course, it just to make two nullable foreign keys. Something like this.
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| prospect_id | int(11) | NO | PRI | NULL | auto_increment |
| ext_status_1_id | int(11) | YES | | NULL | |
| ext_status_2_id | int(11) | YES | | NULL | |
+-----------------+--------------+------+-----+---------+----------------+
In this example there would be, of course, two tables that hold id/value pairs for statuses.
Here's the catch - ext_status_2_id
will always be NULL unless ext_status_1_id
is 1
(this is just how the business rules work).
Have I modeled this correctly? I just have this nagging voice in the back of my brain telling me that "not every row in prospect will need an ext_status_2_id
so this might not be right".
If it matters, this is MySQL 5.0.45 and I'm using InnoDB