What data type to use for a primary key.

A

Angelina

Hi,

I am in the process of trying to created an access
project (Im using MSDE instead of JET 4.0) but im not
sure on what datatype to use.

What i want to do is have a datatype for a key that would
automatically be created (like autonumber in access) when
i insert a new row. It would have to be ensured that the
new value it automatically creates is always unique.

What datatype should i use ofr this??
Also what datatype do i use for this in the child
relation?

If i insert the data a row into the parent relation, can
i have it so that the autonumber generated is also
propogated to the child table as i will always be
insertin into these tables at once.

Any help is appreciated.
 
A

Angelina

thx Kevin,

Is seed the starting value?
Also how can i get the autonumber that is generated to be
placed into the child relation? is there an easy way to
do this?
Or can anyone recommend a suitable method?

thx for your help.
 
T

Tim Ferguson

Angelina said:
What datatype should i use ofr this??
Also what datatype do i use for this in the child
relation?

It's called an IDENTITY type; and you can set the starting value and step
amount explicitly if you want. IDENTITY(1,1) is functionally exactly the
same as an autonumber in Jet.


HTH


Tim F
 
K

Kevin3NF

MSDE has an Identity datatype? Identity property of an INT datatype I see,
but not IDENTITY....of course I'm looking at SQL Server, not MSDE but I
thought they were the same in this regard.

--
Kevin Hill
President
3NF Consulting

www.3nf-inc.com/NewsGroups.htm
 
T

Tim Ferguson

MSDE has an Identity datatype? Identity property of an INT datatype I
see, but not IDENTITY....of course I'm looking at SQL Server, not MSDE
but I thought they were the same in this regard.

Yes, of course you are right, but I got the impression that the OP was
looking for the keyword to create an autonumber-like field, which is

CREATE TABLE T1 (
IdNum INTEGER IDENTITY(1,1) CONSTRAINT pk PRIMARY KEY,
....


and that was the keyword she couldn't find.

By the way, I just noticed this paragraph in the original post
If I insert the data a row into the parent relation, can
I have it so that the autonumber generated is also
propogated to the child table as I will always be
inserting into these tables at once.


which suggests a serious design problem.

B Wishes


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top