Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have a school project to create a simple networking site, And I want to know if my database design is good. I'm open for any suggestions to improve my design thanks!

enter image description here

share|improve this question
2  
Unfortunately it is hard to review code when you have no code. There is no Diagram Review here. – James Khoury Sep 21 '12 at 5:23
It makes no sense to create code for someone else's question. If the OP doesn't have code, they shouldn't have asked the question. – Winston Ewert Oct 9 '12 at 13:49
2  
@WinstonEwert, I created code that corresponded to the ERM diagram. Anyone who is familiar with ERM would agree that the code is directly analogous. Models can be used as code (and often should be) - a lack of familiarity with the graphical notation as "code" does not entail meaninglessness of the code. The OP was asking about his database design. Whether it is represented in SQL or in a graphic model is irrelevant to the content of his question. I merely translated it into a more digestible format for the target audience. – smartcaveman Oct 9 '12 at 13:53
@WinstonEwert, graphical modeling has been recognized as a valid form of encoded logic since the late 1880s ( en.wikipedia.org/wiki/Existential_graph ). If a question used logical symbols that you were unfamiliar with, would it be off topic as well? – smartcaveman Oct 9 '12 at 13:56
1  
@WinstonEwert, I reviewed the meta post you linked to and I do not believe that situation is the same. The convention that "we should not edit code into the questions" is applicable to the copying of code from an external location to a post. This is fundamentally different from translating code (graphical or otherwise) that is already in the post into a more universally accessible format. – smartcaveman Oct 9 '12 at 20:00
show 5 more comments

closed as off topic by Corbin, James Khoury, Brian Reichle, Paul, Glenn Rogers Sep 24 '12 at 13:34

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

  1. I recommend using camel case naming conventions in databases and avoiding abbreviations where possible. It will always be easier to remember LastName than lname, and will be much more convenient when working with ORM tools.

  2. You may want to add a uniqueness constraint on email addresses for users. It rarely makes sense to allow a single email address to have multiple accounts.

  3. In order to maintain consistent data values and enable easy expansion of functionality, you can create a status table. The status field in the Friends table would then be an FK to the status id, instead of an arbitrary value.

  4. In order to add clarity to your model, it would make sense to find a better naming convention than "user_id" and "user_to". This is not very expressive and it is difficult to determine if bidirectional relationships should be represented by one or two Friends records. Perhaps, there should be two records (one for each user that has a friend). Or, perhaps this means that the User who made the initial friend request is the owner of the Friends record. Regardless of how you choose to handle this, it should be more clear.

  5. It is generally good practice to keep a unique database ID in each table. However, it is not necessary if the Friends user_id and user_to will together form a composite primary key. This is a design choice to be made, but I want to point out that the option for omission would be permitted.

    • As a side note, it would be more helpful to other users if you made an effort to include some code (such as an object model or SQL CREATE TABLE statement as well as the datatypes that correspond to your table's columns. I happen to be familiar with ERM, but that is not a fair assumption to make of all CodeReview users.
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.