Here are the problems I can see in theProductType create table:
- A stray closing parentheses
- The column 'group', used in the foreign key constraint, does not exist in table ProductType
- The name 'group' is a reserved word anyway
Here's a working one with the foreign key as a table constraint:
CREATE TABLE ProductType(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
low_level INTEGER,
prod_group INTEGER NOT NULL,
FOREIGN KEY (prod_group) REFERENCES ProductTypeGroup(id)
);
CREATE TABLE ProductType(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
low_level INTEGER,
prod_group INTEGER NOT NULL,
FOREIGN KEY (prod_group) REFERENCES ProductTypeGroup(id)
);
To copy to clipboard, switch view to plain text mode
or as a column constraint:
CREATE TABLE ProductType(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
low_level INTEGER,
prod_group INTEGER NOT NULL REFERENCES ProductTypeGroup(id)
);
CREATE TABLE ProductType(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
low_level INTEGER,
prod_group INTEGER NOT NULL REFERENCES ProductTypeGroup(id)
);
To copy to clipboard, switch view to plain text mode
Bookmarks