Reputation: 588
Evening,
I've no training in Databases, and I'm a bit lost.
Essentially I've this data:
Game
name_of_game varchar(?);
screen_shots ?
screen_shot_1
screen_shot_2
...
screen_shot_n
/Game
What is the best way to store the screen_shot_n data?
Do I try to use a serialized array? Or do I need to try to make another table and store it there? BTW, there are 30k 'Game'
I'm using PHP and MySQL if that'd help in anyway...
Upvotes: 0
Views: 1233
Reputation: 3074
Store them in seperate tables. Something like this:
Table 1: GameInfo Fields: gameid int, nameofgame varchar(X)
Table 2: GameScreenShots Fields: ID int, gameid int, screenshotimage ??(X)
You'll want to have ID's on the table so you can reference the screen shots from the game table. I would recommend them to be integer as using the name of the game for id's can be tricky. Depending on if your storing an actual image of the screenshot or a link to the image will determine the type of your screenshotimage field.
Upvotes: 0
Reputation: 162
Storing images in MySQL is not a good idea. I would suggest that you keep a master table for game name and game ID, then store game ID and timestamp (with an optional random key) in another table. Store the screenshots in a folder in the format timestamp.jpg
Upvotes: 1
Reputation: 5249
I would probably use a separate screen shots table.
Game Table
game_id integer
name varchar
Screenshots Table
screenshot_id integer
game_id integer
screenshot varchar <--- a file name (or a blob or however you are storing the screenshot)
And then you can find the game's screenshots with:
SELECT * FROM screenshots WHERE game_id="123";
Upvotes: 3
Reputation: 463
You will need to create a bin type fields, and store the data there,
Although being its binary data, maybe just use local storage and just link to it from the DB?
YOu can .htaccess it to protect the directory and stream the content with PHP.
Upvotes: 0