Welcome Guest, Not a member yet? Register   Sign In
Help with Foreign Keys
#2

[eluser]gon[/eluser]
You should use foreign keys. Not everybody does, but it makes databases more secure and consistent.

What you would get in the post / comments example is:

* you can't add a comment having the id of a non-existant post.
* you can delete a post and have all of it's comments deleted automatically, or prevent a post from being deleted if a comment exists (depending on how you create the key).

You would link the same way posts and users, assuring that every post has a real user assigned, etc.


Messages In This Thread
Help with Foreign Keys - by El Forum - 10-28-2008, 12:39 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 03:11 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 05:07 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 05:11 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 05:16 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 05:18 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 09:06 AM
Help with Foreign Keys - by El Forum - 10-28-2008, 10:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB