Top "Foreign-keys" questions

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

set null value in a foreign key column?

I have this table CREATE TABLE [dbo].[CityMaster]( [CityID] [int] NOT NULL, [City] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_…

sql-server foreign-keys relational-database constraints relationship
Django - Foreign Key to User model

I want to create new model, something like: user_name = models.ForeignKey(u"Username", User), but when I try to …

django foreign-keys user-registration
Why are foreign keys more used in theory than in practice?

When you study relational theory foreign keys are, of course, mandatory. But in practice, in every place I worked, table …

sql database foreign-keys
SQL Multiple Foreign Keys as Primary Keys

If I declare the table below does it implicitly imply that both the foreign keys make a unique primary key …

sql sql-server sql-server-2008 foreign-keys composite-primary-key
Performance of string comparison vs int join in SQL

It's accepted that searching a table on an int column is faster than on a string column (say varchar). However, …

sql performance join foreign-keys varchar
Is string or int preferred for foreign keys?

I have a user table with userid and username columns, and both are unique. Between userid and username, which would …

mysql sql foreign-keys ddl
MySQL Foreign Key On Delete

I am trying to figure out relationships and deletion options. I have two tables, User and UserStaff, with a 1:n …

mysql foreign-keys relationships
SQL Server foreign key to multiple tables

I have the following database schema: members_company1(id, name, ...); members_company2(id, name, ...); profiles(memberid, membertypeid, ...); membertypes(id, name, ...) [ { …

sql sql-server tsql foreign-keys referential-integrity
Does the foreign keys automatically get updated as primary table is updated?

Above is my simple database design, just wanted to gain information about how things happen as I'm really new at …

sql-server database foreign-keys primary-key rdms
Force InnoDB to recheck foreign keys on a table/tables?

I have a set of InnoDB tables that I periodically need to maintain by removing some rows and inserting others. …

mysql foreign-keys innodb