Menu

[Solved]-Trying Insert Values Table Sqlite Database Getting Error Message Saying Result Foreign Key Q37222314

I am trying to insert values into a table in SQLite database butI am getting an error message saying — Result: foreign keymismatch – “Services” referencing “Subscription”. Here are mycreate table commands for service and subscription tables –

create table Subscription (SubId int primary key NOT NULL,

SubFee Real NOT NULL,

SubType Text NOT NULL,

IDnum Integer,

FOREIGN KEY ( IDnum ) References CustomerInfo( IDnum ) On UpdateCascade

On Delete Restrict);

create table Services (

Services char(50) NOT NULL,

Tid,

FOREIGN KEY (Tid) References Subscription (Tid) On UpdateCascade On Delete Restrict);

The command I attempted to use is: INSERT into Services (Tid,SubId, Services)
VALUES (NULL, ‘10101’, ‘Full Gym’). Feel free to adjust commandsand tables to rectify the mistake.

My other create table commands are:

create table CustomerInfo(IDnum int primary key NOT NULL,FirstName Text NOT NULL, LastName Text NOT NULL, SubType Text NOTNULL, Street char(50) NOT NULL, City Text NOT NULL, state Text NOTNULL, Zipcode int NOT NULL);

create table Trainer (Tid int primary key NOT NULL,

TrainerFirstN Text NOT NULL,

TrainerLastN Text NOT NULL,

IDnum INTEGER,

FOREIGN KEY ( IDnum ) References CustomerInfo(IDnum)

On Update Cascade

On Delete Restrict);

Expert Answer


Answer to I am trying to insert values into a table in SQLite database but I am getting an error message saying — Result: foreign… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *