Why Do I Need To Know about Databases?

You would be forgiven for thinking that databases are only useful in business software and similar applications, but in reality, they can be used as an excellent form of data storage for Java games on a server.

The only other real option that we have other than databases is using files on the server to store the data, but the access would be much slower and files can become corrupt much more easily. In contrast to that though, the simplest type of database is a flat file database, which constitutes the use of normal text files to structure a relational database. This is commonly done with the use of CSV (comma-separated values) to represent the fields of data within the tables and separate files to represent the actual tables of the database. This is how a sample table of information would look in CSV format:

Ian,Smith,24,ian.smith@email.net Jenny,Wethersby,19,jenny@email.net Harry,Ashby,43,h.ashby@email.net Rachel,Henderson,32,r.henderson@email.net Lucy,Jones,18,jones@email.net

This would represent a table that held a user's first name, surname, age, and e-mail address and would be contained in a single flat file.

Although we have little interest in flat file databases, they can be useful for storing backups of data. For example, you could export a database into CSV and write it to a CD-ROM every day to ensure that you have a safe backup. CSV is very easy to import into a database, and we will see this in the next chapter on using a real database package.



Java 1.4 Game Programming
Java 1.4 Game Programming (Wordware Game and Graphics Library)
ISBN: 1556229631
EAN: 2147483647
Year: 2003
Pages: 237

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net