TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-14-2007, 10:07 AM   #1 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default Review my database design

http://www.imgsync.com/data/img/1951...ase-design.PNG

Finally, completed.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Old 12-14-2007, 11:53 AM   #2 (permalink)
The Wanderer
 
bmicallef's Avatar
 
Join Date: Nov 2007
Posts: 18
Thanks: 3
bmicallef is on a distinguished road
Default

Haris,

Would you provide a short narrative of what you are trying to achieve and how you expect the database to be accessed by users?

For example ... if you are planning to search on specific fields, you may want to add indexes to aide faster searching.

If you are looking to expand the database later to support additional content, then you may also want to re-evaluate how your data is normalized, etc ...
Send a message via AIM to bmicallef
bmicallef is offline  
Reply With Quote
Old 12-14-2007, 01:29 PM   #3 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Good thinking bmicallef.

Quick things off the top of my head:
- There is no status table.
- Since you're using tinyint as your datatype for user_rank in your users table, you should do the same the the ID in your users_rank table. Tinyint should be more than enough, especdially if you make it unsigned since it'll go up to 255.
- In your comments table, isn't the comments_comments column a little redundant?
bdm is offline  
Reply With Quote
Old 12-14-2007, 02:37 PM   #4 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Quote:
Originally Posted by bdm View Post
Good thinking bmicallef.

Quick things off the top of my head:
- There is no status table.
- Since you're using tinyint as your datatype for user_rank in your users table, you should do the same the the ID in your users_rank table. Tinyint should be more than enough, especdially if you make it unsigned since it'll go up to 255.
- In your comments table, isn't the comments_comments column a little redundant?
  • I don't need a status table. Not necessary. I will have only two status, hide or show i.e 0 or 1.
  • I'll change them. Between, can you explain difference between signed and unsigned? :)
  • It should be comment_comment. I know it sounds confusing. I have two choices, either stay with it due to the table prefix standard in other tables or just change it to comment. The first option sounds better to me but I'll consider a second opinion.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Old 12-14-2007, 03:15 PM   #5 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

A signed int's range is -2147483648 to 2147483647, a unsigned int's range is 0 to 4294967295
__________________

Village Idiot is offline  
Reply With Quote
Old 12-14-2007, 03:28 PM   #6 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

In your case:
Code:
signed tinyint => -128 to 127
unsigned tinyint => 0 to 255
Check out MySQL AB :: MySQL 5.0 Reference Manual :: 9 Data Types for a more in depth explanation of all data types.

Last edited by bdm : 12-23-2007 at 12:46 AM.
bdm is offline  
Reply With Quote
Old 12-14-2007, 08:17 PM   #7 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

I am sure I'll have more than 255 users, 255 content, 255 ingredients, 255 comments and 255 ratings so i'll stay with unsigned int.

Thanks.
__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote
Old 12-14-2007, 08:35 PM   #8 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

I'm not sure if I'm the only one, but I'm having a hard time distinguishing the relationships. Seems like all the lines cross eachother.

Any way we could get a clearer model please?
bdm is offline  
Reply With Quote
Old 12-14-2007, 10:01 PM   #9 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

First, let me make sure that my data types are correct. I have to make the relationship again if I change data types. :(

http://www.imgsync.com/data/img/7579...se-design1.PNG

A more readable version of relationships.
http://www.imgsync.com/data/img/1621...se-design2.PNG
__________________
Necessity is the mother of invention.

My blog

Last edited by Haris : 12-14-2007 at 10:53 PM.
Haris is offline  
Reply With Quote
Old 12-23-2007, 12:47 AM   #10 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Your users table needs some lovin'.

users
user_rank => tinyint(1)
username seems to be way too long, same with password and name
and i think the hashes password will always be the same length. so it's safe to use char(n)

Sorry, only had a quick second to spare.
bdm is offline  
Reply With Quote
Old 12-29-2007, 10:40 PM   #11 (permalink)
The Wanderer
 
Join Date: Nov 2007
Posts: 9
Thanks: 0
macov is on a distinguished road
Default

Quote:
Originally Posted by Haris View Post
Still there are missing the descriptions of relationships. Looking at your model, I don't know what kind of a reletionship is between USER and CONTENT.

Is a user creating a content, reading, rating, requesting a piece of content, etc? It is good idea to have the names of relationships. Like USER has ACCOUNT, USER belongs to GROUP, GROUP is managed by ADMIN, EMPLOYEE works in DEPT.
macov is offline  
Reply With Quote
Old 12-30-2007, 12:34 AM   #12 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quick question completly off the topic, what program did you use to create that db design???
Tanax is offline  
Reply With Quote
Old 12-30-2007, 04:22 AM   #13 (permalink)
The Wanderer
 
Join Date: Nov 2007
Posts: 9
Thanks: 0
macov is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
Quick question completly off the topic, what program did you use to create that db design???
Whatever it is, don't use it...

I suggest DBDesigner 4

fabFORCE.net
macov is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:14 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design