Composite primary key- newbie question  
Author Message
Oldood





PostPosted: Mon Jun 07 08:36:08 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question

Hi

How to create a composite primary key comprising of two fields from a given table

In the table designer, I specified ascending indexes for the two fields to be defined as primary key. Then I go to the index tab and select the first field, choose primary key option and in the expresion, I give field1+field2. But the database designer shows only the first field as the primary key!

Is this the way to create composite primary key? Or am I missing some step

Regards

Exchange Server15  
 
 
anonymous





PostPosted: Mon Jun 07 08:36:08 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question Hi all

I looked in the foxpro help on creation of composite primary keys! No help is provided. Is a composite primary key option available in vfp8

Please advis
Dona
 
 
Rick





PostPosted: Mon Jun 07 09:09:48 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question Dona,
Not in the table designer, but you can do it in code. This practice is =
really discouraged and in many databases it is simply not allowed.

Rick



> Hi,
>=20
> How to create a composite primary key comprising of two fields from a =
given table?
>=20
> In the table designer, I specified ascending indexes for the two =
fields to be defined as primary key. Then I go to the index tab and =
select the first field, choose primary key option and in the expresion, =
I give field1+field2. But the database designer shows only the first =
field as the primary key!=20
>=20
> Is this the way to create composite primary key? Or am I missing some =
step?
>=20
> Regards
 
 
anonymous





PostPosted: Mon Jun 07 09:41:07 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question Thanks Rick
 
 
anonymous





PostPosted: Tue Jun 08 00:36:03 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question
I had tried that! but after creating the index with option primary key and specifying in the expresion, the 2 fields required, when I come back to the database designer, the key symbol is shown only on one field. In SQL server, the table designer shows key symbol for all the fields participating in the primary key!
 
 
Rick





PostPosted: Tue Jun 08 07:49:30 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question Mark,
You are right, I must have had a "senior" moment - even back in 6.0 SP5, =
I can create a compound PK in the table designer.

Thanks for keeping me honest!

Rick



> Waddayamean "not in the table designer"?????
>=20
> Hi Rick 8-)
>=20
> Of course you can do it in the table designed, although not just by=20
> clicking. On the index page you can type in a tag name and a key=20
> expression. Unless it's changed since VFP7...
>=20
> Mark Stanton
> One small step for mankind...
>=20
>
 
 
trw7at





PostPosted: Thu Jun 10 11:05:42 CDT 2004 Top

Exchange Servers >> Composite primary key- newbie question =?Utf-8?B?RG9uYQ==?= seemed to utter in


> Hi,
>
> How to create a composite primary key comprising of two fields from a
> given table?
>
> In the table designer, I specified ascending indexes for the two
> fields to be defined as primary key. Then I go to the index tab and
> select the first field, choose primary key option and in the expresion,
> I give field1+field2. But the database designer shows only the first
> field as the primary key!
>
> Is this the way to create composite primary key? Or am I missing some
> step?
>
> Regards

Before you commit to a composite primary key in your database
design, I suggest you lookup the many threads that have been
written here about using surrogate integer primary keys. Your
database will be much cleaner and easier to work with. Then
define candidate keys for your multi-field values if you see
fit.

-- TRW
_______________________________________
My e-mail: t r w 7

_______________________________________