pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <postgresql@aranya.com>
To: A. Kretschmer <andreas.kretschmer@schollglas.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Table Relationships
Date: Tue, 31 Oct 2006 13:32:59 -0600
Message-ID: <bf05e51c0610311132w3bb1bb80i876750c9c5d8aee8@mail.gmail.com> (raw)
In-Reply-To: <20061031184843.GA12767@a-kretschmer.de>
References: <031936836C46D611BB1B00508BE7345D04C02E82@gatekeeper.daycos.com>
	<20061031184843.GA12767@a-kretschmer.de>

On 10/31/06, A. Kretschmer <andreas.kretschmer@schollglas.com> wrote:
>
> am  Tue, dem 31.10.2006, um 11:15:26 -0600 mailte Curtis Scheer folgendes:
> > Given the following two tables:
> >
> > CREATE TABLE public.task
> > (
> >   taskid int4 NOT NULL DEFAULT nextval('task_taskid_seq'::regclass),
> >   description varchar,
> >   CONSTRAINT pk_taskid PRIMARY KEY (taskid)
> > )
> >
> > public.users
> > (
> >   userid int4 NOT NULL,
> >   username varchar,
> >   CONSTRAINT pk_userid PRIMARY KEY (userid)
> > )
> >
> > I want to record which user ?performed the task? and which user ?checked
> the
> > task?, I?ve come up with a few ideas on this but I would like to know
> what the
> > correct way would be to implement this into my table design.
>
> Perhaps a table like this:
>
>
> (
>     user int references public.users,
>     task int references public.task,
>     ts timestamptz default now(),
>     action char(1) check (action in ('p','c'))
> )
>
>
> -- with p(perform), c(cheked)


I would go further by adding a type table like this:

operation_type (
    operation_type_id bigserial (PK),
    operation_cd varchar(10),
    operation_name varchar(20)
)

with two codes "perform" and "check" and another table

operation (
    user int references public.users (PK),
    task int references public.task (PK),
    ts timestamptz default now() (PK),
    operation_type_id bigint references operation_type
)

This gives you the flexibility to add more operation types in the future.

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
   http://codeelixir.com
==================================================================

view thread (13+ messages)  latest in thread

Message-ID: <bf05e51c0610311132w3bb1bb80i876750c9c5d8aee8@mail.gmail.com>
Permalink:  ../bf05e51c0610311132w3bb1bb80i876750c9c5d8aee8@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0610311132w3bb1bb80i876750c9c5d8aee8@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgresql@aranya.com, andreas.kretschmer@schollglas.com
  Subject: Re: Table Relationships
  In-Reply-To: <bf05e51c0610311132w3bb1bb80i876750c9c5d8aee8@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox