I was trying to delete a row from a table where no reference is at place and got "foreign key missmatch" . I.e. i got a table which values say a,b references another table's values, let's say a1,b1. I am trying to delete the values a,b which refer to some other values but not refered at.
>Create Table Sensor(
SensorId INT,
RoomId int NOT NULL,
MoistureMeasurementPrecision DOUBLE,
HeatMeasurementPrecision double,
MaximumBatteryLife double,
Manufacturer varchar(20),
Primary key(SensorId,RoomId),
Foreign key(RoomId) references Room(RoomId),
Check (MoistureMeasurementPrecision > 0 & MoistureMeasurementPrecision *<=100),
Check (HeatMeasurementPrecision > 0 & HeatMeasurementPrecision <=100),
Check (MaximumBatteryLife>0));
Create Table Measurement(
TimeofMeasurement TIME,
RoomId INT NOT NULL,
SensorId INT NOT NULL,
Heat DOUBLE,
Moisture DOUBLE,
primary key(RoomId,SensorId,TimeofMeasurement),
foreign key(RoomId) references Sensor(RoomId),
foreign key(SensorId) references Sensor(SensorId),
check(Moisture>0));
sqlite> delete from Measurement where RoomId= 1;
Error: foreign key mismatch - "Measurement" referencing "Sensor"
I do not provide the contents of the tables as my problem is that there is no reference to that table.
Tried the same thing on sqlite studio and got this error:[21:53:30] Error while executing SQL query on database 'First Database': foreign key mismatch - "Measurement" referencing "Sensor".