Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Composite primary keys
Message
From
02/12/2004 08:18:22
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
02/12/2004 08:10:08
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00966059
Message ID:
00966352
Views:
8
>>To enforce the relationships, just use the referential integrity builder that comes with Visual FoxPro, or an alternative RI-builder.
>
>>Whether you use primary keys made up of a single field or composite keys, the relationship is from one index to another index. It works exactly the same way.
>
>I was indeed confused, probably because of my ignorance of the VFP database. I thought that creating a relationship from one index to another was already enforcing data integrity. I have to read some more documentation !

To create the RI:

  • Open the database from the project, or with MODIFY DATABASE.
  • Make sure you have the required indices.
  • From the parent table, drag a primary or candidate index, to a regular index in the child table.
  • You may repeat this for several more relationships.
  • Before continuing with the next step, you may have to pack ("clean up") the database. One of the last commands in the "Database" menu.
  • Right-click on the database area (outside of a table), and select "Referential Integrity".
  • Here, you decide which rules you want to enforce.

    Normally, you would put "Restrict / Restrict / Restrict". In some specific cases, you may want to use cascading delete. If the data in the child table is optional (won't always point to a valid parent), you may put "Ignore" for the "Insert" part.

    You may also want to see my article, http://www.utmag.com/wconnect/wc.dll?9,7,10,1589
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Previous
    Next
    Reply
    Map
    View

    Click here to load this message in the networking platform