Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Jahuran
Jul 9, 2001
Perhaps you guys can give me some advice on the following system I want to build. I'm not really looking for coding advice just your thoughts on what approach to take. I'm building everything on a PHP5 & MySQL5 platform. So sprocs are an option and I have experience with them.

I want to make a small community website where each individual user can can have their own personal page. The users can edit their own personal page to their liking with some javascript colorpicking scripts.

I figured I could do it in a few ways:
  • 1.Store a file on the filesystem per user with their colorpicks in it and load these into a session whenever they return to the website.
  • 2.Store a file on the filesystem per user and load it everytime a user loads up a page.
  • 3.Store the colorsettings in a database table and load them into a session when the user returns to the website.
  • 4.Store the colorsettings in a database table and load them everytime a user loads up a page.

Options 1 and 2 create a heavier load in terms of disk i/o.
Options 3 and 4 create more constant database queries (disk i/o and processing)

Options 3 and 4 seem the most viable to me. I'm expecting around 250 concurrent users daily during normal business hours. When people navigate to eachothers pages the colorpicks of the page they are visiting need to be loaded not their own!

So what method would you guys pick? Is there another way of going about this?
Recommendations are very welcome!

Adbot
ADBOT LOVES YOU

Jahuran
Jul 9, 2001

Standish posted:

Stuff

Sewer Adventure posted:

Stuff

Thanks guys

Jahuran
Jul 9, 2001
I'm having some trouble with a php mysql query / database layout I want to set up. Perhaps someone can point me in the right direction.

I have a main table that holds recipe information.

recipes
recipeID (INT auto_increment PK)
recipeName(VARCHAR)
recipeDescription
dateCreated
dateUpdated
userID

I have a table that holds ingredients

ingredients
ingredientID(INT auto_increment PK)
ingredientName(VARCHAR)
ingredientDescription(VARCHAR)

Then I have a table connecting different ingredients to a recipe

ingredientsRecipes
ingredientRecipeID
recipeID
ingredientID

I want to make a search query that allows me to say: Give me all the recipeIDs that contain eggs,flour,water, etc. However this would require me to query the same table columns multiple times. I'm not completely sure on how to set up a query like that.

Normally I'd say:
code:
SELECT * FROM `ingredientsRecipes` WHERE `ingredientID`='X' AND `ingredientID`='Y';
This wouldn't give me any results since there aren't any rows where the ingredientID is both X and Y.
Perhaps its really simple and I'm missing something. If my table setup is wrong please by all means correct me.

Jahuran
Jul 9, 2001

KuruMonkey posted:

If Begby was correct, ignore this:

If I read you correctly, you want recipes with eggs AND flour AND water? In which case Begby's answer won't be helping you at all, as IN is a shorthand for OR.

What you want is subqueries:

SELECT recipeID FROM recipesIngredients WHERE ingredientID = 'X' AND recipeID IN (SELECT recipeID FROM recipesIngredients WHERE ingredientID = 'Y') AND recipedID IN (SELECT ...

Which basically lets you chain queries together, but have the SQL engine do the lifting for you still.

(caveat: not tested that syntax, but see http://dev.mysql.com/doc/refman/5.0/en/subqueries.html)

Edit: break those tables!
p.s. this was also really an SQL question, there are likely SQL goons that are better at SQL than us PHP goons.

Thank you for the replies. I saw the thread about database questions so I figured my question would be better off there. Above suggestion with IN does work for me.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply