Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'd like to get into online games programming. I thought that as a start i'd be a good idea to implement an online database that would store the progress and score for a game i have made, i'll probably want to implement an account system too.

My issue is, i can't see to be able to ask google the right question. I don't know where to start. I've touched some on SQL and PHP, HTML and XSL, but, to me they're just languages, i can't see the big picture, how do these things connect to form a working service? I'm not looking for a solution, i just don't know what should i learn.

I'm not looking for knowledge on sockets, i'm familiar with network programming, i just don't understand the "modern" process of handling databases. I'd be very happy if somebody could lay out the structure of a database, how you put it out on the web, how you access the information and change it (not in a direct solution, just "this is done by programming a filter in SQL"), what languages are used for it, etc.

share|improve this question
1  
This is not where I would start with making games. Start with the rendering and gameplay first. –  stephelton Feb 15 '12 at 6:15
    
"for a game i have made", i don't think i was being vague here –  dreta Feb 15 '12 at 7:31
    
@stephelton: what if he wants to make a webgame? ^^ –  Lohoris Feb 15 '12 at 8:21
    
@Lohoris he still has to draw things and there is still some gameplay mechanicisms involved... –  stephelton Feb 15 '12 at 15:04
add comment

1 Answer

up vote 4 down vote accepted

The database is the backend, your game is the client. Since you can't (well, technically you can but you really shouldn't) connect to the DB directly, you'll have to write some kind of middleware for that.

The middleware usually runs as a web-service or deamon on a server and exposes an interface for you to access/store game data. This stuff can be implemented in a lot of different languages.. basically any language that you can run on a server and access a database with.

For things like highscores, achievements etc. you can write a simple PHP (or Ruby, Java,..) script that you can access via HTTP. A common architecture for web APIs like this is REST. If you would implement a highscore system as RESTful service, you might have an URL like this:

http://my.server.com/highscores

Sending a GET request to that URL would fetch the scores from the DB and return them (you could send them as XML, JSON or similar).

To add a new score-entry, you maybe have an URL like:

http://my.server.com/highscores/add

And you would send a new Highscore to that address using a HTTP POST request. Then you read out the POST data and insert it into the database.

Of course you don't have to conform to any architecture (such as REST), but I'd say it's good practice.

Here are some things you should be aware of when you do something like this for the first time:

  • Don't trust the client. If your game can send a highscore, anybody else can do so also... this question touches on that topic.

  • Always validate and sanitize incoming data (remember, don't trust the client). Being sloppy with these things will make your service susceptible to SQL injection attacks.

share|improve this answer
    
thank you, at first this didn't sound like the answer i was looking for, but after googling for the past 2 days it all became clear. i create a database, put it on a server, then i create a script as an interface to run on the server and use URLs to query the server and recieve or send the information i want, it's exactly like you've said, i'm just a dummy, thank you so much. –  dreta Feb 16 '12 at 2:18
    
@dreta You got it right. Glad it helped. –  bummzack Feb 16 '12 at 8:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.