No Primary Key

Posts   
 
    
Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 04-Aug-2005 19:37:22   

Hey, I have a table that doesn't have a primary key. It is called UserGroups and just has two foreign keys. When I refreshed the catalog it warned me that there was no primary key, and I may not get code I expected. Should I ignore this warning for this type of situation (I am assuming so, but I wanted to double check)? Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 05-Aug-2005 10:41:44   

Skeeterbug wrote:

Hey, I have a table that doesn't have a primary key. It is called UserGroups and just has two foreign keys. When I refreshed the catalog it warned me that there was no primary key, and I may not get code I expected. Should I ignore this warning for this type of situation (I am assuming so, but I wanted to double check)? Thanks!

Always define a PK on your tables. If you don't you can't insert new entities or update an existing entity. You can also define fields to be the PK in the designer though, in the entity editor.

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 05-Aug-2005 19:39:31   

Skeeterbug wrote:

Hey, I have a table that doesn't have a primary key. It is called UserGroups and just has two foreign keys. When I refreshed the catalog it warned me that there was no primary key, and I may not get code I expected. Should I ignore this warning for this type of situation (I am assuming so, but I wanted to double check)? Thanks!

Assuming the two foreign keys together form a unique key, define it as such in the schema (or, as Frans said, in the Designer). Otherwise, create a surrogate key.

Jeff...