Page 1 of 1
Data size
Posted: Tue Aug 15, 2006 7:31 pm
by Shendemiar
I would want to use minimum space in database to hold data. Traditionally i have gone with a zipped string containing sequenced data. I was wondering how much im wasting space compared to a binary file that has optimized bits for each type of data?
Whats the support for binary file access in php? (never had to find out if it exists or use it)
Can you do "virtual files", so i wouldnt have to mess around creating real files?
Posted: Tue Aug 15, 2006 7:50 pm
by feyd
I hope you're aware that many, if not most, databases automatically compress the data stored in them.
The major file access functions are all binary-safe.
fopen(),
fwrite(),
fclose(),
fseek(),
file_get_contents(), etc etc..
Posted: Thu Aug 17, 2006 10:54 am
by Shendemiar
I know...
Databases compress by default, but according to my experiences (based on what phpmyadmin shows as table size) thats not good enough.
Im designing a game, that would have quite complex map data for each game.
Lets consider few cases:
A cordinate based map data is
1. Stored to a database as one row per cordinate with columns for each x,y,terrain, pop and so on. You dont have to be a wizard to tell it'll be HUGE. (Actually, im usually used char or string, but how about binary and blob?)
2. A zipped var_export of array holding the same data stored in binary blob field. Is by far smaller than option one, and not too complicated to use either.
3. Binary file of type degined only for this task. It guess it would beat the previous even uncompressed. This starts to be bit more complex to use, having to create/access actual files between php and database. (Is that correct?)
4. Some wellknown imageformat stored in the database. Modern imagefiles have layers, that could hold different data, and are also compressed by default, and you could pick the bit-depth to match your needs. Could be quite handy if i know the right classes and filetypes. (Please comment this, what image-file types would do, and would have tested php support for them?)
4.b Many imagefiles, on with more depth for terraintypes or such, one 2bit to hold fog of war, and so on....
Please comment and correct me where im wrong. Im designing and now its easy to change the way.