View Single Post
  #15 (permalink)  
Old 01-12-10, 11:27
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Quote:
Originally Posted by r937 View Post
blindman, i think you're secretly chuckling at how you're messing with us

CREATE TABLE top_level_domains
( tld VARCHAR(9) NOT NULL
);
INSERT INTO top_level_domains VALUES
( 'co.uk' )
,( 'com' )
,( 'ca' )
;

CREATE TABLE emails
( addressee VARCHAR(99) NOT NULL
, domain VARCHAR(99) NOT NULL
, tld INTEGER NOT NULL
, PRIMARY KEY ( tld, domain, addressee )
, FOREIGN KEY ( tld ) REFERENCES top_level_domains ( tld )
);
INSERT INTO emails VALUES
( 'pootle','plushtoys','co.uk' ) -- pootle@plushtoys.co.uk
,( 'blindman','yanks','com' ) -- blindman@yanks.com
,( 'r937','canucks','ca' ) -- r937@canucks.ca


you honestly prefer the surrogate key of my previous post, as compared with the natural key of this post?

if so, you're an idiot, and i say that in the nicest way possible

You can call me an idiot if you like, but you're the one who declared your primary key as varchar(9) and is then trying to define the foreign key as an integer....
....and I point that out in the nicest way possible.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote