Top "Foreign-keys" questions

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

Django "Cannot add or update a child row: a foreign key constraint fails"

I have a model Coupon, and a model Photo with a ForeignKey to it: class Photo(models.Model): coupon = models.…

mysql django orm foreign-keys
Enforce a foreign-key constraint to columns of same table

How to enforce a constraint of foreign key on columns of same table in SQL while entering values in the …

sql oracle foreign-keys self-reference insert-into
Hibernate unidirectional one to many association - why is a join table better?

In this document (scroll down to the Unidirectional section): http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#…

hibernate one-to-many foreign-keys associations
Django 2.0: sqlite IntegrityError: FOREIGN KEY constraint failed

I'm working on adding Django 2.0 support to the django-pagetree library. During automated testing, using an sqlite in-memory database, I'm getting …

python django sqlite foreign-keys django-2.0
MySQL table with a varchar column as foreign key

I am trying to create a table with a varchar column as foreign key but MySql gives me an error …

mysql database-design foreign-keys relational-database
What are the pros and cons for choosing a character varying data type for primary key in SQL?

In the databases course that I did during my education (approx. 4 years ago), I thought that it is recommended avoiding …

sql foreign-keys primary-key postgresql-9.1 sqldatatypes
How to implement ONE-TO-MANY in a database

I want to implement one-to-many concept in my application. This is the scenario: I have two tables (i). Person(ID, …

database-design foreign-keys rdbms
Foreign keys in django admin list display

If a django model contains a foreign key field, and if that field is shown in list mode, then it …

django django-admin foreign-keys
using self referencing in sql server

create table EMP(Eid int primary key) insert into EMP values(11e3) --self referencing alter table EMP add constraint fk_…

sql sql-server sql-server-2005 foreign-keys self-reference
How to alter "REFERENCES" in PostgreSQL?

How can I alter the reference to a table in PostgreSQL when the table name has been changed? Say I …

postgresql foreign-keys ddl alter-table