Welcome Guest, Not a member yet? Register   Sign In
Blog Database Structure - Categories & Meta Tags
#8

[eluser]dmorin[/eluser]
Ran out of room...

So you should be able to work through my naming convention and determine how the relationships work. I also included some joins so you can infer the relationship by reading them. Also note that I included an author_id in the posts table, but didn't show an author's table, which would still have to be completed.

Once you get the structure setup, you should also define the relationships in the database by creating Foreign Key indexes. They are useful to ensure data consistency so you don't add a comment with a post_id that doesn't exist for example. In some engines, you can also define actions for ondelete and onupdate. That way, if you deleted a post and set the ondelete action to cascade, it would also delete the comments. It only cascades down though so if you had categories defined, it would delete the record in categories_posts, but not the category record itself.

I realize this is a lot to digest, but read through it and do some more research on your own and then let us know if you have specific questions.

EDIT:
I just realized I was talking through it calling the primary keys post_id, but then in my queries, I showed them as just id. Sorry if that's confusing. I usually always make the primary key of each table just "id" unless I have a good reason to change it.


Messages In This Thread
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 06:51 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 07:36 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 07:48 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 08:15 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 09:18 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 04:32 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 06:58 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-19-2010, 07:05 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 04-20-2010, 07:11 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-03-2010, 10:11 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-03-2010, 11:54 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-03-2010, 02:05 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-03-2010, 02:30 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-03-2010, 06:01 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-03-2010, 08:42 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 02:02 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 09:58 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 10:10 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 12:05 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 12:21 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 07:05 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-04-2010, 08:38 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-06-2010, 09:17 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-06-2010, 11:50 AM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-06-2010, 12:15 PM
Blog Database Structure - Categories & Meta Tags - by El Forum - 05-06-2010, 02:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB