Stupid foreign key question

Started by Konstantinos Agourosover 24 years ago2 messagesgeneral
Jump to latest
#1Konstantinos Agouros
elwood@agouros.de

Hi,

I am trying to create a database with some cross references. From readings the
doku I am quite sure I didn't understand the use of foreign key/references.

I wrote it the following way:
CREATE TABLE "ccs" (
"name" character varying(20),
"id" integer PRIMARY KEY DEFAULT NEXTVAL('serial')
);
CREATE TABLE "users" (
"name" character varying(10),
"id" integer PRIMARY KEY DEFAULT NEXTVAL('serial'),
"admin" boolean,
"teamid" integer FOREIGN KEY (id) REFERENCES ccs (id)
);

This does not work and does not look right \:) So how do I do this correctly?

Konstantin
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not survive the forming of the cosmos." B'Elana Torres

#2Konstantinos Agouros
elwood@agouros.de
In reply to: Konstantinos Agouros (#1)
Re: Stupid foreign key question

In <elwood.998748473@news.agouros.de> elwood@agouros.de (Konstantinos Agouros) writes:

Hi,

I am trying to create a database with some cross references. From readings the
doku I am quite sure I didn't understand the use of foreign key/references.

OK I took a look at Bruce's book online and fixed it \:)

Konstantin
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not survive the forming of the cosmos." B'Elana Torres