Re: Database design? - Mailing list pgsql-general

From Aasmund Midttun Godal
Subject Re: Database design?
Date
Msg-id 20011023214628.27236.qmail@ns.krot.org
Whole thread Raw
In response to Re: Database design?  ("Aasmund Midttun Godal" <postgresql@envisity.com>)
List pgsql-general
Err. CREATE TABLE entities that is.
On Tue, 23 Oct 2001 16:26:43 GMT, "Aasmund Midttun Godal" <postgresql@envisity.com> wrote:
> Ok let me try to explain how I would do it:
>
> CREATE TABLE languages (
>     "language" TEXT PRIMARY KEY,
> );
>
> CREATE SEQUENCE description_seq;
>
> CREATE TABLE descriptions (
>     id PRIMARY KEY, -- You could make this default
> -- curval('description_seq')
> -- if you are absolutely 100% sure only one person inserts at the time.
>     description TEXT NOT NULL,
>     language REFERENCES languages NOT NULL,
>     UNIQUE(id, language)
> );
>
> CREATE TABLE authors (
>     id DEFAULT nextval('decription_seq') PRIMARY KEY,
>     firstname TEXT,
>     lastname TEXT NOT NULL,
>     unique(firstname, lastname)
> );
>
> CREATE TABLE books (
>     id DEFAULT nextval('decription_seq') PRIMARY KEY,
>     title,
>     author REFERENCES authors NOT NULL,
>     book bytea,
>     unique(title, author)
> );
>
> This is the basic structure.
>
> Now if you like you can have a map table - although I am not sure I would.
>
> CREATE TABLE languages (
>     "language" TEXT PRIMARY KEY,
> );
>
> CREATE SEQUENCE description_seq;
>
> CREATE TABLE entities (
>     id DEFAULT nextval('decription_seq') PRIMARY KEY
> );
>
> CREATE TABLE descriptions (
>     id REFERENCES entities PRIMARY KEY, -- You could make this default
> -- curval('description_seq')
> -- if you are absolutely 100% sure only one person inserts at the time.
>     description TEXT NOT NULL,
>     language REFERENCES languages NOT NULL,
>     UNIQUE(id, language)
> );
>
> CREATE TABLE authors (
>     id REFERENCES entities PRIMARY KEY,
>     firstname TEXT,
>     lastname TEXT NOT NULL,
>     unique(firstname, lastname)
> );
>
> CREATE TABLE books (
>     id REFERENCES entities PRIMARY KEY,
>     title,
>     author REFERENCES authors NOT NULL,
>     book bytea,
>     unique(title, author)
> );
>
> On Tue, 23 Oct 2001 06:47:30 -0700 (PDT), Rich Shepard <rshepard@appl-ecosys.com> wrote:
>
> Aasmund Midttun Godal
>
> aasmund@godal.com - http://www.godal.com/
> +47 40 45 20 46
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46

pgsql-general by date:

Previous
From: Jani Averbach
Date:
Subject: Re: Charset problem
Next
From: Stephanie.Wall@newriders.com
Date:
Subject: Free PostgreSQL book