• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Database Design and ER diagrems

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am building a Inventory Management System.
I am having doubts about my ER diagram please can someone check my ER.
Many thanks      
 
Saloon Keeper
Posts: 23882
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only thing that really catches my attention is that you're using 45-character VARCHAR fields for your keys (IDs).

Usually you'll get better database performance using numeric keys. Plus it's less trouble if you're generating keys automatically with no inherent meaning (that is, simply to point to stuff).

If those 45 character fields are essential text, you could always define them as secondary keys and flag them as UNIQUE.

 
Indusara Umayanga
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Only thing that really catches my attention is that you're using 45-character VARCHAR fields for your keys (IDs).

Usually you'll get better database performance using numeric keys. Plus it's less trouble if you're generating keys automatically with no inherent meaning (that is, simply to point to stuff).

If those 45 character fields are essential text, you could always define them as secondary keys and flag them as UNIQUE.


Thank you very much for your reply. I'll make those improvements.
What do you think about the foreign keys between user and request is there any better way to do that.
And do you think that there is a circular reference between Comment, Request and User
 
Tim Holloway
Saloon Keeper
Posts: 23882
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Indusara Umayanga wrote:
Thank you very much for your reply. I'll make those improvements.
What do you think about the foreign keys between user and request is there any better way to do that.


No, it's perfectly reasonable, although as previously mentioned, I'd use numeric IDs.

Indusara Umayanga wrote:
And do you think that there is a circular reference between Comment, Request and User



Actually, Comment looks like a Many-to-Many join table to me.

I wouldn't use it like that unless it was constrained further, however, since as it stands you could confuse things by having more that one Comment with the same userid/Requestid pair.
 
Indusara Umayanga
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

Indusara Umayanga wrote:
Thank you very much for your reply. I'll make those improvements.
What do you think about the foreign keys between user and request is there any better way to do that.


No, it's perfectly reasonable, although as previously mentioned, I'd use numeric IDs.



Indusara Umayanga wrote:
And do you think that there is a circular reference between Comment, Request and User



Actually, Comment looks like a Many-to-Many join table to me.

I wouldn't use it like that unless it was constrained further, however, since as it stands you could confuse things by having more that one Comment with the same userid/Requestid pair.



Thank you very much I'll do that for the ids.

Yeah it works like a many to many join table because there can be multiple comments from multiple users.

Can you suggest a better approach for this.

 
Tim Holloway
Saloon Keeper
Posts: 23882
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Off the top of my head, I think that if you define a compound key on User and Request and define it as UNIQUE, that will do it.

Although at that point you would no longer need a separate key for Comment, just use the compound key as primary key.
 
Indusara Umayanga
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Off the top of my head, I think that if you define a compound key on User and Request and define it as UNIQUE, that will do it.

Although at that point you would no longer need a separate key for Comment, just use the compound key as primary key.



Thank you I'll try that.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic