Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

Saving queries and optimizing a database

$
0
0

I'm creating a script that is designed to query a list of posts by selecting a category, sub category and another sub, or by selecting all.

The problem is that when I want to show 'all' posts I need to create 3 queries for each post (to convert the category number into name).

Is there a way to make it more optimized?

Tables structure:

posts:

  • id (int)
  • main_cat (main category) (int)
  • sub_cat (sub category) (int)
  • sub_sub_cat (sub to the sub) (int)
  • description (varchar)

main_cat:

  • id (int)
  • name (varchar)

sub_cat:

  • id (int)
  • relation (int) (id of the main_cat)
  • name (varchar)

sub_sub_cat:

  • id (int)
  • relation (int) (id of the sub_cat)
  • name (varchar)

Thanks in advance.


Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>