Field as both Primary and Foreign Key
I'm using (evaluating) a data modelling tool and have situations where I
have fields that need to be part of the primary key for a table, and also be
a foreign key to another table. This particular product will not let me do
this, a field has to be one or the other. Since I haven't previously tried
to enforce actual server level foreign key contraints, I wasn't sure if this
was a limitation of this product, or whether there is some valid reason why
this isn't a good design and the product is trying to "protect" me.
A simple example, basically a table that acts as an intersection for two
other tables:
Class Table
ClassCode (Primary)
Data
Type Table
TypeCode (Primary)
Data
ClassType Table
ClassCode (Primary & FK)
TypeCode (Primary & FK)
Data
Data
I've done this type of design for years in many different systems and, IMO,
is normal and proper. Do I need a different data modeller, or a lesson in
RDBMS design? If the former (hopefully), than I'd welcome some endor{*word*224}ts
of your favorite SQL data-modelling tool.
Thanks
* Wayne Niddery - WinWright Consulting
* Host of RADBooks at http://home.ican.net/~wniddery/RADBooks.html
* -- Amazon.com Associate -- Delphi, C++Builder, JBuilder, InterDev
* ...remove X when replying...