if a database contains a table defined like this
CREATE TABLE supplierTable ( supplierID integer UNIQUE NOT NULL PRIMARY KEY AUTOINCREMENT,
tenantId text REFERENCES tenantTable ( tenantId) )
and there IS NO SUCH field ‘tenantid’ in the table tenantTable
Should SOMETHING bad happen? an error, an exception or something?
Pretty sure it depends on the database… Postgres will give an error when you try to create the table. SQLite I am not sure and it may depend on if the Foreign Key Pragma is on or not.
Does it throw an error upon an insert into the supplierTable?
Is it possible to create the supplierTable (without inserting any records) before creating the tenantTable.
I ask because I just read a blurb which said that MySQL references would throw an error on insert–leaving it an open question of whether any errors would be produced on creating the table.
What are references in MySQL?
The references keyword is used to define which table and column is used in a foreign key relationship. This means that a record in the hobby table must have a person_id that exists in the person table or else at the time of insert you will receive an error that the key does not exist.