jeudi 5 mai 2016

SQL Foreign Key Mismatch

I am using SQLite and am continuously receiving this error when trying to commit data to the subscriber table. I have tried to find answers here and although some exist I am still struggling to understand what the problem is. I am trying to create a table named 'subscriber' that lists a user's email and the names of channels they subscribe to. I have included my tables below. Any help would be greatly appreciated. Thank you!

Error while commiting new row: foreign key mismatch - "subscriber" referencing "channel"

User Table:

CREATE TABLE user (email varchar (30) PRIMARY KEY, password varchar (20), name varchar (40));

Channel Table:

CREATE TABLE channel (url VARCHAR (50) PRIMARY KEY UNIQUE NOT NULL, name VARCHAR (30), creatorEmail VARCHAR (30) REFERENCES user (email), category VARCHAR (20), numOfVideos INTEGER (10), numbOfSubscribers INTEGER (9));

Subscriber Table:

CREATE TABLE subscriber (email VARCHAR (30) PRIMARY KEY REFERENCES user (email) NOT NULL, channelName VARCHAR (30) REFERENCES channel (name));

Aucun commentaire:

Enregistrer un commentaire