开发者

MySQL design problem

I am trying to normalize my database but I'm having a headache getting to grips with it. I am developing a CMS where Facebook users can create a page on my site. So far this is wha开发者_开发百科t I have

page
----
uid            - PK AI
slug           - Slug URL
title          - Page title
description    - Page description
image          - Page image
imageThumbnail - Thumbnail of image
owner          - The ID of the user that created the page
views          - Page views
timestamp      - Date page was created

user
----
uid  - PK AI
fbid - Facebook ID
(at a later date may add profile options i.e name, website etc)

tags
----
uid - PK AI
tag - String (tag name)

page_tag
--------
pid - Page id (uid from page table)
tid - Tag id (uid from tag table)

page_user
---------
pid - Page id (uid form page table)
uid - User ID (uid from user table)

I've tried to seperate as much information as needed without going over the top. I created a seperate table for tags because I don't want tag names being repeated. If the database holds 100,000+ pages, the repeated tags will add to storage and speed no doubt.

Is there any problems with the design? Or anything I'm doing wrong? I remember learning this at university but I've done very little database design since then.

I'd rather get it right the first time then have the headache later on.


Looks fine to me. How bad can it be with five tables?

You have users, pages, and tags. Users can have many pages; pages can be referred to by many users. A page can have many tags; a tag can be associated with many pages.

Sums it up for me. I wouldn't worry about it.

Your next concern is indexes. You'll want an index for every WHERE clause that you'll use to query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜