Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto make to fields the primary key? 2

Status
Not open for further replies.

RedLion

Programmer
Sep 13, 2000
342
NL
Hello,

A question about how to use the database in foxpro:
- How to make in the first table two fields the primary key?
- And how to make in a second table the two fields from table one with another field together the primary key from the second table?
- And how can a relation made between the fields from table one to table two with a one-to-more relation?

Table1 Table2
prim. ID 1----n prim. ID
prim. WorkID 1----n prim. WorkID
OtherField prim. OurID
AnOtherField1
AnOtherField2


I know that it can be done easily in Ms Access, but how to do this in VFP?

Thanks,

Charl
 
If you are combining the codes then yes..
STR(ID)+STR(workid) into a single "myID"..

Two Primary keys are not allowed ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Table1..
STR(id)+STR(WorkId) can be a primary Key

Table 2
STR(id)+STR(WorkId) can be a regular Index
STR(id)+STR(WorkId)+STR(ourId) can be a primary Key

Hope this helps

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
You can also use a candidate key.

HTH,
Weedz (Wietze Veld) They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best. - Steve McConnell
 
Thanks Ramani and Weedz,

Strange that you can't make two fields the primary key on a Access way, because it's a standard thing with the theory of normalising databases!!!

And it's a difficult way of checking relations, because you have to make a regular key in the second table with the two fields combined to one field. And you have to make two fields in the second table to pas both fields for using it to search and so on, because of filtering on one field in the combined regular index is a little bit difficult.
And to check referential integrity is also difficult for the two fields in the second table in this way.

What's the best approach for such situation?

Thanks,

Charl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top