3 Replies - 594 Views - Last Post: 23 September 2013 - 07:25 AM Rate Topic: -----

#1 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,226
  • Joined: 08-June 10

[MongoDB] RPG DB Design

Posted 23 September 2013 - 04:49 AM

Hi folks,

I’m coding for an RPG system and I’m unsure what data I should put in which table. currently I have 2 tables, one for character statistics (appearance, age, pros/cons, etc.) that almost never change, and one for ability details (ability name, how to test, further details).

there will be one table that links the ability table with the character table (adding the ability value for the character.

and my question now is, where should I place the character data that change on a regular basis (like experience points, equipment, etc.)? I could put it in the character table, but that is already quite packed ...

any ideas are appreciated.

Dormi

Is This A Good Question/Topic? 0
  • +

Replies To: [MongoDB] RPG DB Design

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3462
  • View blog
  • Posts: 11,727
  • Joined: 12-December 12

Re: [MongoDB] RPG DB Design

Posted 23 September 2013 - 05:04 AM

You could put the information in a character_data table that is in a one-to-one relationship with the character table (the character_id is a primary key in both tables).

When you create a new character (in the character table) you could also insert a new (initially empty) row in the character_data table. Otherwise, you would have to keep using the equivalent of INSERT ON DUPLICATE UPDATE all over the shop, when adding/updating character-data.

This post has been edited by andrewsw: 23 September 2013 - 05:08 AM

Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,226
  • Joined: 08-June 10

Re: [MongoDB] RPG DB Design

Posted 23 September 2013 - 05:05 AM

yea, I guess it will end up like that.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,226
  • Joined: 08-June 10

Re: [MongoDB] RPG DB Design

Posted 23 September 2013 - 07:25 AM

extended question: should I use nested documents or rather merge multiple tables?
(note that I can only update one at a time)

i.e.
var charTalentSchema = new Schema({
	talentid:  { type: IDREF,  required: true },
	wert:      { type: Number, required: true, min: -3, max: 35 },
	Spezialisierungen: [String]
});

var charDataSchema = new Schema({
	charid: IDREF,
	SF: {
		Kampf:     [String],
		Manöver:   [String],
		allgemein: [String],
		magisch:   [String],
		geweiht:   [String]
	}
	AP: {
		alle: { type: Number, min: 0, required: true },
		frei: { type: Number, required: true }
	},
	Talente: {
		Kampf:        [charTalentSchema],
		körperlich:   [charTalentSchema],
		Gesellschaft: [charTalentSchema],
		Natur:        [charTalentSchema],
		Wissen:       [charTalentSchema],
		Handwerk:     [charTalentSchema],
		Sprachen:     [charTalentSchema],
		Schriften:    [charTalentSchema],
		Meta:         [charTalentSchema]
	}
});

vs.

var charDataSchema = new Schema({
	charid: IDREF,
	SF: {
		Kampf:     [String],
		Manöver:   [String],
		allgemein: [String],
		magisch:   [String],
		geweiht:   [String]
	}
	AP: {
		alle: { type: Number, min: 0, required: true },
		frei: { type: Number, required: true }
	}
});


var charTalentSchema = new Schema({
	charid:   IDREF,
	talentid: IDREF,
	wert:      { type: Number, min: -3, max: 35 },
	spezialisierungen: [String]
});

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1