Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB stored on different server from queries 2

Status
Not open for further replies.

dmacster

Technical User
Jan 28, 2005
670
US
Hi -

I have a DB that will be hosted separately from the server where the php pages and images.

In one of my text fields, I'm passing the path to an image (images/img1.jpg and so on). Should I use the absolute URL in the DB fields ( or just the relative URL? I'm not sure how the interaction with the queries takes place - if the queries/php that are the main server take precedence.

Thanks for any advice,
Donna
 
Personally, I would save the images as BLOBs in the database, but otherwise, I'd prefer a relative path. Should you need to move the webserver for some reason, the absolute paths may need changed in the code.

Just my $.02.

Mark
 
Thanks, Mark. The client's host couldn't provide mySQL (they're extremely small) for them, so we have to keep the DB separate. The images and php stuff will all be on one host, with the DB on the second.

Donna
 
I weould avoid the use of BLOBS and just use a relative path. The database is supplying the path info to the site server, so that will be the root for your picture path.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
I on the other hand would not save the images as Blobs. it makes maintenance of images extremely difficult, and requires adding large amounts of additional code to display the images.
?Not to mention it can bloat your DB vbery quickly, and should something happen to your storage server your images are wiped out. Its easy to recreate a DB structure, but to recreate images inside not so much.

Back to the question though: the location of the DB should in no way affect the relativeness of the paths to the images. Since they are in the same server as the PHP server, it can access them normally. The fact that you are storing something like: ../images/image.jpg in a server where that path is invalid does not preclude PHP from actually using that path where it is valid, or the web server form serving the images where they actually do reside.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Wonderful - thanks for the advice. Makes it easier to upload without having to change all of my path names.

Thanks,
Donna
 
Wow, I didn't realize...everyone hates BLOBs (maybe just for images).

I guess if you're stuck with a mysqldump backup, that could be problematic at times. I use mysqlhotcopy, so I don't have to worry about binary issues. The only problem is if a restore is necessary, mysql has to be restarted.

Come to think of it, at this time, I have no blobs replicating. I'll test that tomorrow. I'm almost done setting up two new servers so I won't have to worry about breaking something in production.

Later,
Mark
 
Not everyone hates blobs !
They have advantages such as the images are in one place. If you have a farm of servers to support your system you will either have to share a single location around all the servers or have some kind of distribution strategy to share them around the farm.
Having them in the db also allows you to manage things a bit better as you can back up the entire database and so eveything will be in sync whereas if you back up the db and potentialy several file sytems they will easily get out of sync.
Also having them in the db allows any client capable of connecting to it the ability to access the images, whereas on a file system you will have to have the priv's and the physical access mecansisim to get to them e.g. ftp
The microsoft sharepoint system holds everything in a database just to make management easier.
So I think you need to think about what it is you want to do with the images, how big your app will get in terms of servers and how you might want to use the images in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top