Small typographical mistake

Dear list,

In section 2.2 of "A direct mapping of relational data to RDF", the
following snippet of code can't be executed because "Department" is
mispelled:

CREATE TABLE Addresses (
	ID INT,
	city CHAR(10),
	state CHAR(2),
	PRIMARY KEY(ID)
)

CREATE TABLE Deparment (
	ID INT,
	name CHAR(10),
	city CHAR(10),
	manager INT,
	PRIMARY KEY(ID),
	UNIQUE (name, city),
	FOREIGN KEY(manager) REFERENCES People(ID)
)

CREATE TABLE People (
	ID INT,
	fname CHAR(10),
	addr INT,
	deptName CHAR(10),
	deptCity CHAR(10),
	PRIMARY KEY(ID),
	FOREIGN KEY(addr) REFERENCES Addresses(ID),
	FOREIGN KEY(deptName, deptCity) REFERENCES Department(name, city)
)

In addition, the two last tables uses "cross" foreign keys (Department
points to People, and People points to Department)

This is embarassing because one can't just copy and paste the SQL code to
make some experiments (which is what I want to do), I propose the following
code to replace it:

CREATE TABLE Addresses (
	ID INT,
	city CHAR(10),
	state CHAR(2),
	PRIMARY KEY(ID)
);

CREATE TABLE Department (
	ID INT,
	name CHAR(10),
	city CHAR(10),
	manager INT,
	PRIMARY KEY(ID),
	UNIQUE (name, city)
	-- , FOREIGN KEY(manager) REFERENCES People(ID) -- [added below]
);

CREATE TABLE People (
	ID INT,
	fname CHAR(10),
	addr INT,
	deptName CHAR(10),
	deptCity CHAR(10),
	PRIMARY KEY(ID),
	FOREIGN KEY(addr) REFERENCES Addresses(ID),
	FOREIGN KEY(deptName, deptCity) REFERENCES Department(name, city)
);

ALTER TABLE Department ADD FOREIGN KEY(manager) REFERENCES People(ID);

I hope this may help ...

Fabian Pijcke

Received on Monday, 10 October 2011 15:17:51 UTC