Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

unable to create one-to-one relationship

$
0
0
I'm unable to create one-to-one relationship in multiple databases ( mysql, db2). here is my declaration:

--<ScriptOptions statementTerminator=";"/>

CREATE SCHEMA "mydb";

CREATE TABLE "mydb"."first" (
"id" BIGINT NOT NULL
)
DATA CAPTURE NONE
COMPRESS NO;

CREATE TABLE "mydb"."second" (
"id" BIGINT NOT NULL
)
DATA CAPTURE NONE
COMPRESS NO;

ALTER TABLE "mydb"."first" ADD CONSTRAINT "prima_PK" PRIMARY KEY
("id");

ALTER TABLE "mydb"."second" ADD CONSTRAINT "seconda_PK" PRIMARY KEY
("id");

ALTER TABLE "mydb"."first" ADD CONSTRAINT "first_second_FK" FOREIGN KEY
("id")
REFERENCES "mydb"."second"
("id")
ON DELETE CASCADE;
this declaration produces one-to-many relationship both on mysql and db2. anyone could help me on this topic ?

Viewing all articles
Browse latest Browse all 13329

Trending Articles