Oliver,
Your first solution

CREATE TABLE customer(
  id                INTEGER PRIMARY KEY AUTOINCREMENT,
  customernumber    INTEGER,
  customerorigin    INTEGER,
  name              TEXT,
  UNIQUE(customernumber,customerorigin)
  );

is the better of the two because it simplifies foreign keys: the OrderHeader
table would contain a single-column reference to CUSTOMER rather than two
columns.  Either approach is legitimate as far as RDBMS design is concerned;
however some client-side application frameworks and middleware libraries do
not support multi-column primary keys.

Regards
Tim Romano
Swarthmore PA



On Wed, Jun 9, 2010 at 1:37 PM, Oliver Peters <oliver....@web.de> wrote:

> Rich Shepard <rshep...@...> writes:
>
> >
> > On Wed, 9 Jun 2010, Oliver Peters wrote:
> >
> > > So I assume that it is not(!) a mistake not(!) to use a composite PK in
> my
> > > table "customer" (customernumber,customerorigin) and to refer to it
> from
> > > the table "order" where I had to use these fields as a composite FK?
> >
> > Oliver,
> >
> >    Too many negatives there for me to really follow what you're asking.
>
>
> sorry, I try my very best:
>
> adverted to the table customer I've 2 possible solutions and I ask myself
> if the
> first one is incorrect - the reason why I ask lies in the behaviour of my
> frontend (OpenOffice Base) that has problems to handle UNIQUE-Constraints
> under
> special circumstances (main-subform-connections)
>
> solution 1
> ----------
> CREATE TABLE customer(
>   id                INTEGER PRIMARY KEY AUTOINCREMENT,
>   customernumber    INTEGER,
>   customerorigin    INTEGER,
>   name              TEXT,
>   UNIQUE(customernumber,customerorigin)
>   );
>
>
> solution 2
> ----------
> CREATE TABLE customer(
>    customernumber    INTEGER,
>   customerorigin    INTEGER,
>   name              TEXT,
>    PRIMARY KEY(customernumber,customerorigin)
>   );
>
> thx for your patience
> Oliver
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to