Why is the following foreign key constraint (although executes fine) not enforced by SQLite? How can I go about enforcing the relationship?
CREATE TABLE User (
UserID TEXT Unique NOT NULL PRIMARY KEY,
FirstName TEXT NOT NULL,
LastName TEXT NOT NULL,
Username TEXT NOT NULL,
Password TEXT NOT NULL,
Email TEXT NOT NULL,
SignupDate TEXT NOT NULL
)
CREATE TABLE Category (
CategoryID TEXT Unique NOT NULL PRIMARY KEY,
UserID TEXT,
FOREIGN KEY(UserID) REFERENCES User(UserID)
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…