wood burning stoves 2.0*
The moose likes JDBC and the fly likes Primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Primary key" Watch "Primary key" New topic

Primary key

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179

I am getting the pkgid which is unique from the other application and i am supposed to store it in my database.When the other application requests the info related to Pkgid, i need to send the information from my application.
Do i need create the id as number for Primary key or can i use the same package id as primary key. Which is the best way to approach?

id number number
pkg_id varchar2 50

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38007
Don't know, but if the package ID really is unique, why not try it as a primary key?
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
You can use it.
But remember that,primary keys are used for making relationship between two or more tables.
If you want only uniquness,then you can also make unique key.
As you may be aware,both theses keys have differences.

PK has to be unique and not null.
But UK can be null.

Baseet Ahmed
I agree. Here's the link: http://aspose.com/file-tools
subject: Primary key
Similar Threads
Hibernate many-to-one composite key as foreign key
How to assign primary key
to find the primary key of a table
Retrieving Primary key
Subquery in Hibernate 2.0