Your postinstall_user table is defined as: If you refer back to the result of the pragma command, it say that there is a foreign key defined in the postinstall_user table that references the postinstall table, that has a problem. In this particular case, the third bullet, above, is the reason why you are having an issue. Primary key columns and the number of primary key columns in the parent do not * The child table references the primary key of the parent without specifying the Sequence specified in the CREATE TABLE, or Key of the parent table and are not subject to a unique constraint using collating * The parent key columns named in the foreign key constraint are not the primary * The parent key columns named in the foreign key constraint do not exist, or The English language error message for foreign key DML errors is usually "foreign key mismatch" but can also be "no such table" if the parent table does not exist. So, in other words, misconfigured foreign key constraints that require looking at both the child and parent are DML errors. Errors reported when content is changed are "DML errors" and errors reported when the schema is changed are "DDL errors". Instead, such errors prevent the application from preparing SQL statements that modify the content of the child or parent tables in ways that use the foreign keys.
If the database schema contains foreign key errors that require looking at more than one table definition to identify, then those errors are not detected when the tables are created. If the parent key columns have a UNIQUE index, then that index must use the collation sequences that are specified in the CREATE TABLE statement for the parent table. If they are not the primary key, then the parent key columns must be collectively subject to a UNIQUE constraint or have a UNIQUE index. Usually, the parent key of a foreign key constraint is the primary key of the parent table. Why are you getting that error? The following excerpt from the SQLite documentation will shed some light on the issue:
Result : foreign key mismatch - "postinstall_user" referencing "postinstall" The pragma command will not find all foreign key errors, just the ones that the processor can detect at the time. When you execute the command on the DB that you attached, you will see the following error. However, I will try to answer your specific question as to why you are getting this particular foreign key error, how you can begin to trouble shoot such issues in SQLite in the future, and one way that you can resolve this particular error.įirst, to identify glaring foreign key issues, you can execute the following SQLite pragma command on the database. I am not going to go into all of those issues since this is primarily an AutoIt forum not a SQL and/or database forum. Having worked with databases for over 30 years, and after looking over your database definitions, I see several issues with your database that should be corrected, restructured, or optimized. If someone can explain why, I am sure it is an obvious reason for someone who knows what they are doing 😄 If I delete either a user or installer, the related info in the installer_user and postinstall tables are removed but since I added the postinstall_user table to link usernames to the postinstall action, this is where I get the foreign key error. I have managed to get that part working for the most part.
All the fields relating to that user will be removed. The idea with the editing side is to be able to delete an installer from the installer table say with the id of 1 and all other pertinent information in the other tables will also be deleted. Now there wil be one program that deals with the installation side and another that acts as a front end for editing the database suchs as adding new files, removing old files etc. I might separate into two tables, undecided yet.
#Android studio sqlite autoincrement integer non primary key install#
Stores the users\computers that are allowed to run the post install actions Postinstall - a list of activities to perform when the main install has finished. Platform - the OS architecture the installer file is compiled for. Package - stores the type of installer, NSIS, Inno Nullsoft etc. Stores the user or computer to install the program for or on. Installer - this is the main table that has relationships with the other tables and stores info about the installer file, install order etc. I have attached the database thus far and the tables function are as follows:-Ĭategory - stores text describing the general usage the installer comes under, such as Browser, Compression etc.
The database is going to store information about setup installers, such as paths, installer specific info, users to install for, type and category of installer blah, blah. I am using SQLite Expert to design the database and test sql queries. I am trying to normalise a database to remove duplicate info.