-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE goodparent (
    id INTEGER NOT NULL,
    fulnam VARCHAR(20),
    PRIMARY KEY(id)
)
GO
CREATE TABLE goodchild (
    id INTEGER NOT NULL,
    val INTEGER,
    parent_id INTEGER,
    PRIMARY KEY(id),
    FOREIGN KEY (parent_id) REFERENCES goodparent(id)
)
GO

INSERT INTO goodparent VALUES (1, 'A')
GO
INSERT INTO goodparent VALUES (2, 'BB')
GO
INSERT INTO goodparent VALUES (3, 'CCC')
GO
INSERT INTO goodchild VALUES (11, 101, 1)
GO
INSERT INTO goodchild VALUES (12, 102, 1)
GO
INSERT INTO goodchild VALUES (21, 103, 2)
GO

CREATE TABLE badparent (
    id INTEGER NOT NULL,
    fulnam VARCHAR(20),
    PRIMARY KEY(id)
)
GO
CREATE TABLE badchild (
    id INTEGER NOT NULL,
    val INTEGER,
    parent_id INTEGER,
    PRIMARY KEY(id)
)
GO

INSERT INTO badparent VALUES (1, 'A')
GO
INSERT INTO badparent VALUES (2, 'BB')
GO
INSERT INTO badparent VALUES (3, 'CCC')
GO
INSERT INTO badchild VALUES (11, 101, 1)
GO
INSERT INTO badchild VALUES (12, 102, 1)
GO
INSERT INTO badchild VALUES (21, 103, 2)
GO

