Top "Foreign-keys" questions

Foreign keys are a data integrity feature of relational (and SQL) databases.

MySQL Drop foreign key Error 152

I am trying to drop a number of foreign keys using: ALTER TABLE `table` DROP FOREIGN KEY `fk_table_users1` , …

mysql foreign-keys alter-table
MySQL - Conditional Foreign Key Constraints

I have following comments table in my app: comments -------- id INT foreign_id INT model TEXT comment_text TEXT ... …

mysql sql database-design foreign-keys polymorphic-associations
Foreign key with multiple columns from different tables

Let's take a stupid example : I have many domestic animals, each one with a NAME as an id and a …

sql database database-design foreign-keys multiple-tables
How to CASCADE a delete from a child table to the parent table?

I prepared a fiddle which demonstrates the problem. CREATE TABLE parent ( parent_id integer primary key ); CREATE TABLE child ( child_…

sql postgresql database-design foreign-keys cascade
Deleting from multiple tables with foreign constraints

I am trying to delete from multiple tables. Here's what my tables look like A_has_B ---- B ---- …

mysql sql foreign-keys sql-delete
has_many :through with a foreign key?

I've read multiple questions about this, but have yet to find an answer that works for my situation. I have 3 …

ruby-on-rails foreign-keys associations has-many-through
what are the advantages of defining a foreign key

What is the advantage of defining a foreign key when working with an MVC framework that handles the relation? I'm …

sql-server database-design foreign-keys relational-database
MySQL Error Code 1452 Foreign Key Constraint

I'm receiving an error when I attempt to create two tables. There was a multivalued dependency, so I separated the …

mysql sql database foreign-keys mysql-error-1452
Django migration error :you cannot alter to or from M2M fields, or add or remove through= on M2M fields

I'm trying to modify a M2M field to a ForeignKey field. The command validate shows me no issues and …

django foreign-keys migration manytomanyfield
ORMlite Android foreign key support

I am not clever from ORMlite documentation. Is is possible to declare in class, that this parameter is foreign key? …

android foreign-keys ormlite