Top "Foreign-keys" questions

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

Adding foreign key to existing table gives error 1050 table already exists

I've a table CustomizationSet with the columns: customization_set_guid (which is a non-nullable guid and also the primary key) …

mysql foreign-keys mysql-workbench mysql-error-1050
MySQL - Using foreign key as primary key too

I have table 1 with a primary key user_id and table 2 where user_id is a foreign key. Only 1 record …

mysql foreign-keys primary-key foreign-key-relationship primary-key-design
Identifying Sybase tables, fields, keys, constraints

I'm trying to set up a Sybase query that will give me the following output: Table KeyType KeyNumber Column table1 …

foreign-keys primary-key key sybase sysobjects
MySQL foreign keys on self

I'm currently trying to make a self referencing table in MySQL, however it seems I can't make a foreign key …

mysql foreign-keys self-reference
mysql alter int column to bigint with foreign keys

I want to change the datatype of some primary-key columns in my database from INT to BIGINT. The following definition …

mysql foreign-keys int alter bigint
How do I create a table with self-referencing fields in MySQL?

In GTFS, the field parent_station is either from stop_id (self-reference) or NULL. For instance (note that parent_station …

mysql foreign-keys create-table self-reference gtfs
CONSTRAINT to check values from a remotely related table (via join etc.)

I would like to add a constraint that will check values from related table. I have 3 tables: CREATE TABLE somethink_…

postgresql database-design foreign-keys constraints referential-integrity
Django ORM - select_related and order_by with foreign keys

I have a simple music schema: Artist, Release, Track, and Song. The first 3 are all logical constructs while the fourth (…

django foreign-keys sql-order-by django-select-related
Linq To SQL Without Explicit Foreign Key Relationships

I am working with a few legacy tables that have relationships, but those relationships haven't been explicitly set as primary/…

linq linq-to-sql class foreign-keys associations
Django: How to get data connected by ForeignKey via Template?

Since a few weeks I am learning Python and Django. Up to this point it has been enough to read …

django templates foreign-keys django-related-manager