CREATE TABLE coworkers ( id serial PRIMARY KEY, name varchar(63) );
CREATE TABLE email_types ( type VARCHAR(10) PRIMARY KEY ); INSERT INTO email_types VALUES ('home'); INSERT INTO email_types VALUES ('work'); CREATE TABLE emails ( owner INTEGER REFERENCES coworkers, type INTEGER REFERENCES email_types, --You could have a CHECK --instead offcourse. email VARCHAR(127) PRIMARY KEY, preferred BOOLEAN, UNIQUE(owner, preferred), UNIQUE(type, owner) ); No guarantees, I have not run it, but I think it should work. On Wed, 10 Oct 2001 13:39:31 -0700, Jeff Davis <[EMAIL PROTECTED]> wrote: > I was wondering is there is a good method to make a database field a > pointer, similar to C. Here is an example I made up of why this could be > useful: > Suppose I have a table 'coworkers' with 2 email address fields: work_email > and home_email. It would be useful to have another field that was something > like 'preferered_email' that pointed to one or the other. Then, updates would > only need to happen once, and it would be easy to change back and forth. > Tell me if there is some better, more sensible method to accomplish this > task. > > Thanks, > Jeff Davis > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] Aasmund Midttun Godal [EMAIL PROTECTED] - 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