Re: same sequence as primary key in more than one table
Date: Mon, 15 Jun 2009 09:32:26 -0700 (PDT)
On Jun 15, 7:02 am, Shakespeare <what..._at_xs4all.nl> wrote:
> student4life schreef:
> > Hello,
> > For example, I have 'sellers' and 'buyers' both need to authenticate
> > from a database table 'users' with sequence as primary key which is
> > also as primary key in tables 'sellers' and 'buyers' (both have one-to-
> > one relationship with 'users') but I am not sure whether it's good
> > practice to have sequence number jumping alternatively between tables.
> > Could someone inform me what the best practice/design is under the
> > scenario? TIA
> As long as sequences and there values don't have a significant meaning,
> there is no problem with using the same sequence for different tables.
> It's a matter of taste and standards. Some standards require a separate
> sequence for each table, some standards don't.
> I wonder though: is the primary key in 'sellers' the same value as the
> primary key in 'users', so if a seller has, let's say, 1676 as primary
> key, is the primary key value in 'users' 1676 as well?
Yes, and my plan is to first generate the primary key for 'users' for new users not yet existed in the 'users' table (by search criteria like authenticated username and password combination) and depending on whether this user is a 'buyer' or 'seller', to replicate and insert this same sequence value as primary key in the correct table. For example, 2 new users of 1 buyer and 1 seller sequentially register in that order would sequentially generate primary key value of '101' for 'users' and 'buyers' tables and '102' for 'users' and 'sellers' tables, respectively. Thanks. Received on Mon Jun 15 2009 - 11:32:26 CDT