I am building a templates site with MySQL backend. I am storing the background images, CSS, etc for the layout all in the database. So everytime someone views a webpage at XYZ persons site, it pulls the content from my database. Now assuming my website takes off and I get lets say 1000 people to use my templates. That could mean 1000's of queries hitting my database at once to pull down background images. **************************** I've been building it this way because it makes it easier. When i create the template I dont have to manually edit the <img src="someoutsidesite/somefilename.jpg"> The database takes care of all that for me! End result for me... I dont have to spend hours hand coding templates because its all filled out by SQL. But what are the long term results. Can mySQL handle my needs if my site becomes popular?
Are you storing the image files themselves in the database or simply their path? Also, are your database and web server the same machine or separate (or do you not even have a web server)? The best set up would be to have seperate web and database servers. This may not be under your control if you are paying for hosting. Store the files on the web server. Store the path in the database. You can use the path so that you do not have to manually edit anything.
...or if you are worried about people giving others the templates, you could give people the db code and just use a callback in the code. In other words, you let them upload the code to their db and use an encrypted call back so the code will only work on such and such a domain, it also lets you maintain control without the server load.
What I can see is that you are creating a site that will be available only if MySQL is up, but bearing in mind so at the first problem with database your visitors will only see errors ir you are not disabling error reporting, in which case only will see white pages. If you own your own server, it is more likely the problem does not occur or can be fixed easier, but if you are on a shared hosting it's more likely that you face some MySQL error at some point.
yeah everything is stored in the DB and the site template is dependant on MySQL being up. So for instance someone copies my CSS code to use for their profile. The CSS will call the background image from the database like <img src="http://mydomain.com/display?id=1254"> Where the background image is in row 1254. So yeah I had it so each page will pull the background blob from the database. But now I'm thinking this may be taxing on MySQL especially when people get tons of site hits. But its alot easier for me to have my PHP inject that string where I need it in my CSS code im uploading than hand code. I did it originally that way because when I upload a site I can upload the thumbnail / CSS code / and background image. And let the PHP/MySQL handle all the work of creating the correct links to the background image in my CSS code. Thus alleviating me from having to create 1000s of custom image names and hand coding the IMG tags.
It depends on how your site is coded really, a few database query is fine,but if you run a query for every image displayed it can get heavy fast.
the slowest thing on a php page is the mysql part for the 90% of the time. do as less queries as you can. and always optimize your queries with EXPLAIN to select as less rows as possible...
also storing images in the database (at lest that is what I understand that you are doing) requires a tremendous amount of database space and work for the database engine. I would be MUCH better to only store urls for images in the database and store the actual images somewhere else. You can write code to add and delete the images at the same time that you update the database. So when you delete an image in the database it automatically deletes the image in your storage folder. The CSS and other text can be stored in the database fine though.