A type of integrity constraint used in a RDBMS platform to ensure that a value in a column matches one of a range of key values from another table.
4
votes
2answers
680 views
Does a view need its own foreign key constraints?
Disclaimer: I'm a programmer, not a DBA, so bear with me...
I have a view that I use to just map 2 entities together. I have to do a join between a few different tables to get that:
CREATE OR ...
5
votes
1answer
2k views
MySQL, foreign key, can't create table error 150
UPDATE: Sorry, it was because i forgot to add UNSIGNED attribute to the lang_id column.
Original:
I'm trying to create a table with foreign key in MySQL.
I get this error: #1005 - Can't create table ...
8
votes
2answers
565 views
What is the purpose of SET NULL in Delete/Update Foreign Keys constraints?
I am probably being narrow minded, but if I create a foreign key constraint and a row gets updated or deleted, I lose that connection if the child table's column gets set to NULL.
What is the purpose ...
3
votes
1answer
597 views
Foreign Key constraint on fixed value field
Note: I am a developer...
I have an Asset table that has many codes that are foreign keys into a second table OutlineFiles. The OutlineFiles table has Type and Code as the primary key. The foreign ...
1
vote
1answer
214 views
InnoDB Foreign key updating vs. manual in-application updating
I've been working on a "legacy" schema in MySQL Workbench that uses a lot of relations. All of the tables are MyISAM, however, and there are no foreign keys.
However, I'm working on a new area of the ...
4
votes
2answers
529 views
Using IDs from multiple tables in a single column
One of my co-workers created a schema similar to the following. This is a simplified schema including only the parts necessary to address this question.
The system rules are as follows:
...
2
votes
1answer
131 views
InnoDB foreign key and index duplication?
I'm have a part table like this:
part_id INT
manufacturer_id INT
supplier_id INT
part_number VARCHAR(50)
part_description VARCHAR(120)
with foreign ...
0
votes
1answer
122 views
Derived value not calculating as expected using combination of FK and Triggers (MySQL)
I'm having trouble with calculating a derived value using a combination of triggers and foreign key constraints.
There are 3 tables involved in this arrangement
responses
------------------------
...
0
votes
2answers
637 views
Query PostgreSQL 9.0 table on foreign key value?
Noob-type question:
Say I have two tables, candies and colors. The colors table holds just code/value pairs like 01 yellow, 02 blue, 03 green, etc. and is referenced in the candies table by code.
...
5
votes
2answers
2k views
Non-unique multicolumn foreign key
I have a "comments" table that models a conversation on a topic, like this:
id serial
topic_id integer
parent_comment_id integer
body text
So, every comment has a reference to its topic AND ...
2
votes
1answer
382 views
Question on Design for User + User Groups + User Types + Subscriptions Model
I am redeveloping an existing web application with both weak source code and a weak underlying database design. I'm trying to develop things in a way that future expansion will be much easier, ...
3
votes
1answer
705 views
Foreign Key violation - not sure why
I have the following two tables with a foreign key on status_id:
mysql> describe usr_cookbook;
+-----------+-----------+------+-----+-------------------+-------+
| Field | Type | Null | ...
9
votes
3answers
178 views
Are there any database engines which will intuit the join condition based on the existing foreign keys?
It seems strange to me that, when I've defined a foreign key, the engine cannot use this information to automatically figure out the correct JOIN expressions, but instead requires me to re-type the ...
5
votes
3answers
227 views
What does the output of a JOIN statement look like?
I've been wanting to use joins for a while, but I'm having trouble visualizing the output so I know how to put it to use.
Let's say I have 2 tables:
CREATE TABLE Cities (
id INT UNSIGNED PRIMARY ...