Question

I have many objects of this structure:

~ PlaceID
  = Upvotes
  = Downvotes
  = Names
    - Title 
      + Upvotes
      + Downvotes
    - Other names[]
      + Upvotes 
      + Downvotes
  = Location
    - Lat
    - Long
    - Address
  = Images
    - Top 
      + id/url
      + Upvotes
      + Downvotes
    - Others[]
      + Upvotes
      + Downvotes
  = Comments[]
    - id
    - Text
    - Upvotes
    - Downvotes
    - ReplyTo

To keep organized, I've laid out a schema that involves a lot of links. This is an example table:

7741 (PlaceID)

______________________________________________________________________________
names      | location      | upvotes | downvotes | images      | Comments
_______________________________________________________________________________
7741_names | 7741_location |    20   |     3     | 7741_images |  7741_comments

then in, say, 7741_images (sorted by score so "Top" item is easy to retrieve):


 imgID   | score | upvotes | downvotes | url              |
________________________________________________________
 7741_21 | 98    |    44   |     1     | /img/7741_21.png |
 7741_14 | 94    |    40   |     2     | /img/7741_14.png |

Will this drill-down style with a lot of tables per object make querying really slow or very specific queries overly wordy? (for 100k places?)

I have never been responsible for schema design so excuse me if I am missing the obvious.

Was it helpful?

Solution

Whether it is bad or good is a quality that is subjective -- based on the question (and schema) you have posed. To better answer that question, it would be essential for you to explain your schema design decision. You should always have a good reason for your decisions, and if in your development it proves incorrect, then iterate to improve. :)

Assuming you are doing a up-front attempt at designing the schema to support your app, I would start out with the approach Neil has pointed out. With your sample schema, under certain circumstances, performance would be an issue.

Again, start simple, and if you need to revise, then just make sure you feel "good" about having a valid reason for your design choice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top