Quote:
|
"unitID + BuildingID" as the primary foreign/composite key.
|
I don't understand this. (unitid, buildingid) as the primary key sounds a bit odd.
It smells (without knowing more) that you want unitid as the PK for the unit table (but this is pure speculation based on the names you have chosen)
Why do you think unitid needs to go into the foreign key? A foreign key consists of the same columns as the referenced primary key. In your case this is only buildingid.
I don't really know SQLite but in standard SQL this would be written as:
Code:
CREATE TABLE Unit
(
unitID INTEGER NOT NULL,
BUILDINGID INTEGER NOT NULL,
CurrOccID VARCHAR(50),
size VARCHAR(50),
imgPath VARCHAR(50),
comment VARCHAR(30),
PRIMARY KEY (unitid, buildingid),
FOREIGN KEY (buildingid) REFERENCES building
);