Skip site navigation (1) Skip section navigation (2)

Re: Darn pop singers!

From: "Jon Poulton" <jon(at)illumining(dot)com>
To: "Ian Pilcher" <i(dot)pilcher(at)comcast(dot)net>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: Darn pop singers!
Date: 2004-05-11 14:18:20
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Why not simply have a 'Stage name' column, which may or may not be the same
as the real name? Or perhaps an 'alias' column, which is of type TEXT, which
contains a comma separated list of aliases? Also- you cant be sure that the
firstname/lastname combination is unique, so I wouldnt have this as a

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Ian Pilcher
Sent: 11 May 2004 14:49
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] Darn pop singers!

Apologies in advance if this is a dupe....

Sorry if this is a FAQ.  My Google skills are failing me.

I'm in the initial stages of designing a database for my super-, ultra-,
uber-web jukebox application -- which is really a vehicle for me to
learn RDBMSes, SQL, JSPs, servlets, etc.  Right now, I'm trying to
come up with the best way to model musical artists -- singers, song-
writers, etc.

The problem is that these people have an annoying habit performing under
multiple stage names.  David Bowie, born David Jones, also released
music under the name Arnold Corns.

Here is my current approach:

CREATE SEQUENCE person_info_id_seq;

CREATE TABLE person_info (
     id INTEGER DEFAULT nextval('person_info_id_seq') PRIMARY KEY,
     real_id INTEGER DEFAULT currval('person_info_id_seq') NOT NULL
         REFERENCES person_info,
     last_name TEXT NOT NULL,
     first_name TEXT DEFAULT '' NOT NULL,
     UNIQUE (last_name, first_name)

So I might have this:

  id | real_id | last_name  | first_name
   4 |       4 | Jones      | David
   5 |       4 | Bowie      | David

David Jones is a "real" name, because id = real_id.  I do not want to
allow Arnold Corns to be added with real_id = 5 (since David Bowie is
not a "real" name), so I've done this:

     'SELECT $1 = (SELECT real_id FROM person_info WHERE id = $1) AS

ALTER TABLE person_info ADD CHECK (id = real_id OR

I can't help feeling, however, that this is a bit kludgy.  Can anyone
suggest a better way?


Ian Pilcher                                        i(dot)pilcher(at)comcast(dot)net

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

In response to

pgsql-novice by date

Next:From: Oliver FrommeDate: 2004-05-11 14:31:43
Subject: Re: Darn pop singers!
Previous:From: Ian PilcherDate: 2004-05-11 13:48:31
Subject: Darn pop singers!

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group