Linked Questions
25 questions linked to/from What's wrong with foreign keys?
24 votes
8 answers
41k views
Should I use foreign keys? [duplicate]
Possible Duplicate: What’s wrong with foreign keys? I use MS Sql Server with a large database about 4 GB data. I search around the web why I should use foreign keys. by now I only indexed the ...
3 votes
0 answers
4k views
What is the advantages in using foreign keys and disadvantages in not using? [duplicate]
I always create my tables thinking about how they will relate and then put then to work with no dependencies. FK declarations sometimes make tables harder to alter when there is data already, so I don'...
2 votes
1 answer
1k views
Why would someone not use Foreign Keys in a MySQL database? [duplicate]
I'm confused about something, time and again i've seen developers including team leaders tell me that using foreign key constraints on their DB is bad practice, that it adds "logic to the database" ...
138 votes
24 answers
53k views
Why are foreign keys necessary in a database design? [closed]
Foreign keys help the programmer to manipulate data. If a programmer is doing this already, then do we need the concept of foreign keys? What are other uses for foreign keys? What am I missing?
8 votes
6 answers
6k views
Pros and cons of programmatically enforcing foreign key than in database
It is causing so much trouble in terms of development just by letting database enforcing foreign key. Especially during unit test I can’t drop table due to foreign key constrains, I need to create ...
26 votes
4 answers
26k views
How to cascade delete document in mongodb?
I have user and photo documents in Mongodb. Each photo belongs to user and a photo maybe shared among users. Lets say user1 has p1,p2,p3 photos and user2 has p3,p4,p5 photos. If I delete user1 (...
6 votes
7 answers
5k views
Should every table have a primary key?
I read somewhere saying that every table should have a primary key to fulfill 1NF. I have a tbl_friendship table. There are 2 fields in the table : Owner and Friend. Fields of Owner and Friends are ...
4 votes
3 answers
2k views
Creating relationships between tables
My question specifically about sql-server, but probably can be answered by anyone with any database background If I want table A to have a 1:1 relationship with table B on a certain column, should I ...
5 votes
1 answer
2k views
On Postgres databases, does relationship constraints degrade performance?
This is my first post here and I've tried to do my homework. I need to have a better way to develop Data Warehouse databases for Postgres than using Power*Architect. Here is the complete sad history:...
5 votes
1 answer
3k views
How do foreign keys work?
I've mostly used MyISAM tables before, which don't support foreign keys. Looking on stack overflow I didn't find a nice, concise explanation of what a foreign key is actually doing. I'm mostly ...
8 votes
2 answers
733 views
Do large systems use foreign keys in their databases? [closed]
One of the disadvantages people point to with using foreign keys in a relational database is the overhead of making sure the parent table exists before doing any insert operation. (Example). As your ...
4 votes
1 answer
788 views
Create a Django field which behaves like a ForeignKey but queries through a join?
I have two database tables which are logically related through a CharField. For example, a survey response which asks for a phone number, and a person which has a phone number: class SurveyResponse(...
-1 votes
3 answers
717 views
Mysql error Cannot add foreign key constraint when i add foreign key
IN my mysql database i have two table review and products mysql> desc review; +---------------+--------------+------+-----+-------------------+----------------+ | Field | Type | ...
0 votes
1 answer
1k views
Proper way to make a relation between multiple rows of single table
I've got following situation: I want to connect multiple records from one table with some kind of relation. Record could have no connection to other, or could have multiple of them (1 or more). There ...