Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Foreign Key Programmatic Syntax?
Message
From
10/01/2001 18:14:33
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00461952
Message ID:
00461983
Views:
10
>Trying to hand-code some database creation, specifying primary and candidate and foreign keys.
>
>Does anyone have any sample code showing foreign key generation between n tables?
>
>VFP6/SP4.
>
>Thanks.

Primary and Foreign key creation - table must be in a database to use these
create data test
create table one (id i primary key, ctest c(10))
create table many (id i, ctest c(10))
index on id tag id
alter table many add foreign key tag id references one tag id
Candidate keys are created using the Candidate keyword in the INDEX command (tables do not have to be in a database to have candidate keys)., e.g.,
index on id tag id candidate
If you already have a database, run GenDBC (or GenDBCX) - it comes with VFP - against it. Throw all the goodies you can into the database (pk's, fk's, relations, stored procedures, etc.) and learn from the GenDBC output file how to handle each thing.
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform