Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you provide some advice on setting up my database?

I'm working on a MUD (Multi User Dungeon) in Python and am just now getting around to the point where I need to add some rooms, enemies, items, etc. I could hardcode all this in, but it seems like this is more of a job for a database.

However, I've never really done any work with databases before so I was wondering if you have any advice on how to set this up?

  • What format should I store the data in?
    • I was thinking of storing a Dictionary object in the database for each entity. In htis way, I could then simply add new attributes to the database on the fly without altering the columns of the database. Does that sound reasonable?
  • Should I store all the information in the same database but in different tables or different entities (enemies and rooms) in different databases.

  • I know this will be a can of worms, but what are some suggestions for a good database? Is MySQL a good choice?

like image 928
samoz Avatar asked Dec 18 '25 00:12

samoz


2 Answers

1) There's almost never any reason to have data for the same application in different databases. Not unless you're a Fortune500 size company (OK, i'm exaggregating).

2) Store the info in different tables.

As an example:

  • T1: Rooms

  • T2: Room common properties (aplicable to every room), with a row per **room*

  • T3: Room unique properties (applicable to minority of rooms, with a row per property per room - thos makes it easy to add custom properties without adding new columns

  • T4: Room-Room connections

    Having T2 AND T3 is important as it allows you to combine efficiency and speed of row-per-room idea where it's applicable with flexibility/maintanability/space saving of attribute-per-entity-per-row (or Object/attribute/value as IIRC it's called in fancy terms) schema

Good discussion is here

3) Implementation wise, try to write something re-usable, e.g. have generic "Get_room" methods, which underneath access the DB -= ideally via transact SQL or ANSI SQL so you can survive changing of DB back-end fairly painlessly.

For initial work, you can use SQLite. Cheap, easy and SQL compatible (the best property of all). Install is pretty much nothing, DB management can be done by freeware tools or even FireFox plugin IIRC (all of FireFox 3 data stores - history, bookmarks, places, etc... - are all SQLite databases).

For later, either MySQL or Postgres (I don't do either one professionally so can't recommend one). IIRC at some point Sybase had free personal db server as well, but no idea if that's still the case.

like image 189
DVK Avatar answered Dec 19 '25 20:12

DVK


  • This technique is called entity-attribute-value model. It's normally preferred to have DB schema that reflects the structure of the objects, and update the schema when your object structure changes. Such strict schema is easier to query and it's easier to make sure that the data is correct on the database level.
  • One database with multiple tables is the way to do.
  • If you want a database server, I've recommend PostgreSQL. MySQL has some advantages, like easy replication, but PostgreSQL is generally nicer to work with. If you want something smaller that works directly with the application, SQLite is a good embedded database.
like image 28
Lukáš Lalinský Avatar answered Dec 19 '25 20:12

Lukáš Lalinský



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!