Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referential Integrity & Insert
Message
From
23/01/1999 20:04:35
 
 
To
23/01/1999 12:49:42
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00179374
Message ID:
00179490
Views:
26
>OFFICE TITLES table: This table holds names and descriptions of office titles (Ex. would be Mayor, Governor, County Commissioner, etc.) The primary key for this table is ntitle_id
>
>OFFICES table: this table holds all the information you could ever want to know about an office (Ex. when the office will have its next election, description of office, precincts of that office, region of that office, etc.)
>
>OFFICE TITLES is the parent and OFFICES is the child table.
>
>My understanding of the "restrict" option for the insert is that it prohibits any additions to the child table if there isn't a related record in the parent.

You are correct here. What you have specified is that you do not want to be able to add a record to 'Offices' unless it holds a reference to an office title that already exists. This means also, that a record with an empty ntitleid is not allowed.

Is this what you are seeing?

One way to get around this (if getting around it is what you want) is to add a record to OfficeTitles with 0 as the key. This would allow records to be appended to Offices with blank (0) values in the nTitleid field.


Generally, this type of relationship, though technically '1-many' I refer to as a lookup. I make the distinction by asking if the OfficeTitles table holds any additional information about the entity it represents, of it is just a key and a value.

Now what kind of referential integrity you want to enforce on this relationship is really up to you, the programmer. Your instructor was correct in that always restricting inserts will keep your data pristinely clean. I don't practice this, however, because I have found that there is always an exception to the rule. Your users will always want to enter an office before they know the title. You could argue that this only makes a case for adding an 'Office Title Unknown' record to the titles table, but I have just found it easier to enforce this woth code. Everybody will have their own preferences on how to handle this.

If you think you are observing behavior different from what you think it should be doing, give a detailed example of what you are reying to do, and we'll see if we can figure out what is happening.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform