How to handle multiple user save games of a RPG in SQL
up vote
0
down vote
favorite
I have a complex RPG video game under development and it supports multiplayers, matchmaking, and cloud save game. For a lot of reasons, we are handling the "cloud save" ourselves - mainly for cross platform support.
For this, we created a SQL database on our servers, and for now we have a "users" table handling the different login, password, save, Steam/PlayStation/etc ID, and anything unique to a user. We have a "saves" table, and that's where I feel we can improve. The table definition looks like this:
CREATE TABLE saves (
id uniqueidentifier PRIMARY KEY,
user_id INT NOT NULL,
create_date DATETIME NOT NULL,
edit_date DATETIME NOT NULL,
name text NOT NULL,
data text NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
The place I feel is lacking the data text NOT NULL
, where right now we simply feed a Json'ed of a save game. In a RPG, a player may have an inventory, a number of quests, different NPC dialog states and so on. However, from what I understand there is no "clean" way of doing arrays inside a table cell in SQL. Having each saves game being in a different table would be terrible, as we could end up with tens or hundreds of tables.
Is there something we are overlooking, or is using a cell to store a serialized version of the save data the best I can do in SQL?
sql arrays json
|
show 3 more comments
up vote
0
down vote
favorite
I have a complex RPG video game under development and it supports multiplayers, matchmaking, and cloud save game. For a lot of reasons, we are handling the "cloud save" ourselves - mainly for cross platform support.
For this, we created a SQL database on our servers, and for now we have a "users" table handling the different login, password, save, Steam/PlayStation/etc ID, and anything unique to a user. We have a "saves" table, and that's where I feel we can improve. The table definition looks like this:
CREATE TABLE saves (
id uniqueidentifier PRIMARY KEY,
user_id INT NOT NULL,
create_date DATETIME NOT NULL,
edit_date DATETIME NOT NULL,
name text NOT NULL,
data text NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
The place I feel is lacking the data text NOT NULL
, where right now we simply feed a Json'ed of a save game. In a RPG, a player may have an inventory, a number of quests, different NPC dialog states and so on. However, from what I understand there is no "clean" way of doing arrays inside a table cell in SQL. Having each saves game being in a different table would be terrible, as we could end up with tens or hundreds of tables.
Is there something we are overlooking, or is using a cell to store a serialized version of the save data the best I can do in SQL?
sql arrays json
You have the option of storting json data into your database. Otherwise almost all of the database have support for storing xml.
– George Joseph
Nov 20 at 5:32
@GeorgeJoseph : I know, that's what I said I was doing. Is there a way to store Json other than by a "text" data type? But my goal was to not just dumb a huge string and go "That's the data" and be more "This cell holds the inventory, this cell holds the stats, this cell holds the quests". I assume this is impossible?
– LightStriker
Nov 20 at 5:36
It is possible to create user defined type and store it in the database table. The user defined type would contain the attributes. See an example in oracle database : oracle-base.com/articles/misc/object-views-and-nested-tables
– George Joseph
Nov 20 at 5:45
You could use either XML or JSON and build SQL views to give you an easy query mechanism. In a way expand the json into relational view. It might not be the most performant. blogs.msdn.microsoft.com/sqlserverstorageengine/2015/12/09/….
– Akrion
Nov 20 at 5:46
@Akrion That's just for views, no? I still need to store the data as a string?
– LightStriker
Nov 20 at 5:54
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a complex RPG video game under development and it supports multiplayers, matchmaking, and cloud save game. For a lot of reasons, we are handling the "cloud save" ourselves - mainly for cross platform support.
For this, we created a SQL database on our servers, and for now we have a "users" table handling the different login, password, save, Steam/PlayStation/etc ID, and anything unique to a user. We have a "saves" table, and that's where I feel we can improve. The table definition looks like this:
CREATE TABLE saves (
id uniqueidentifier PRIMARY KEY,
user_id INT NOT NULL,
create_date DATETIME NOT NULL,
edit_date DATETIME NOT NULL,
name text NOT NULL,
data text NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
The place I feel is lacking the data text NOT NULL
, where right now we simply feed a Json'ed of a save game. In a RPG, a player may have an inventory, a number of quests, different NPC dialog states and so on. However, from what I understand there is no "clean" way of doing arrays inside a table cell in SQL. Having each saves game being in a different table would be terrible, as we could end up with tens or hundreds of tables.
Is there something we are overlooking, or is using a cell to store a serialized version of the save data the best I can do in SQL?
sql arrays json
I have a complex RPG video game under development and it supports multiplayers, matchmaking, and cloud save game. For a lot of reasons, we are handling the "cloud save" ourselves - mainly for cross platform support.
For this, we created a SQL database on our servers, and for now we have a "users" table handling the different login, password, save, Steam/PlayStation/etc ID, and anything unique to a user. We have a "saves" table, and that's where I feel we can improve. The table definition looks like this:
CREATE TABLE saves (
id uniqueidentifier PRIMARY KEY,
user_id INT NOT NULL,
create_date DATETIME NOT NULL,
edit_date DATETIME NOT NULL,
name text NOT NULL,
data text NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
The place I feel is lacking the data text NOT NULL
, where right now we simply feed a Json'ed of a save game. In a RPG, a player may have an inventory, a number of quests, different NPC dialog states and so on. However, from what I understand there is no "clean" way of doing arrays inside a table cell in SQL. Having each saves game being in a different table would be terrible, as we could end up with tens or hundreds of tables.
Is there something we are overlooking, or is using a cell to store a serialized version of the save data the best I can do in SQL?
sql arrays json
sql arrays json
asked Nov 20 at 5:29
LightStriker
12.6k21724
12.6k21724
You have the option of storting json data into your database. Otherwise almost all of the database have support for storing xml.
– George Joseph
Nov 20 at 5:32
@GeorgeJoseph : I know, that's what I said I was doing. Is there a way to store Json other than by a "text" data type? But my goal was to not just dumb a huge string and go "That's the data" and be more "This cell holds the inventory, this cell holds the stats, this cell holds the quests". I assume this is impossible?
– LightStriker
Nov 20 at 5:36
It is possible to create user defined type and store it in the database table. The user defined type would contain the attributes. See an example in oracle database : oracle-base.com/articles/misc/object-views-and-nested-tables
– George Joseph
Nov 20 at 5:45
You could use either XML or JSON and build SQL views to give you an easy query mechanism. In a way expand the json into relational view. It might not be the most performant. blogs.msdn.microsoft.com/sqlserverstorageengine/2015/12/09/….
– Akrion
Nov 20 at 5:46
@Akrion That's just for views, no? I still need to store the data as a string?
– LightStriker
Nov 20 at 5:54
|
show 3 more comments
You have the option of storting json data into your database. Otherwise almost all of the database have support for storing xml.
– George Joseph
Nov 20 at 5:32
@GeorgeJoseph : I know, that's what I said I was doing. Is there a way to store Json other than by a "text" data type? But my goal was to not just dumb a huge string and go "That's the data" and be more "This cell holds the inventory, this cell holds the stats, this cell holds the quests". I assume this is impossible?
– LightStriker
Nov 20 at 5:36
It is possible to create user defined type and store it in the database table. The user defined type would contain the attributes. See an example in oracle database : oracle-base.com/articles/misc/object-views-and-nested-tables
– George Joseph
Nov 20 at 5:45
You could use either XML or JSON and build SQL views to give you an easy query mechanism. In a way expand the json into relational view. It might not be the most performant. blogs.msdn.microsoft.com/sqlserverstorageengine/2015/12/09/….
– Akrion
Nov 20 at 5:46
@Akrion That's just for views, no? I still need to store the data as a string?
– LightStriker
Nov 20 at 5:54
You have the option of storting json data into your database. Otherwise almost all of the database have support for storing xml.
– George Joseph
Nov 20 at 5:32
You have the option of storting json data into your database. Otherwise almost all of the database have support for storing xml.
– George Joseph
Nov 20 at 5:32
@GeorgeJoseph : I know, that's what I said I was doing. Is there a way to store Json other than by a "text" data type? But my goal was to not just dumb a huge string and go "That's the data" and be more "This cell holds the inventory, this cell holds the stats, this cell holds the quests". I assume this is impossible?
– LightStriker
Nov 20 at 5:36
@GeorgeJoseph : I know, that's what I said I was doing. Is there a way to store Json other than by a "text" data type? But my goal was to not just dumb a huge string and go "That's the data" and be more "This cell holds the inventory, this cell holds the stats, this cell holds the quests". I assume this is impossible?
– LightStriker
Nov 20 at 5:36
It is possible to create user defined type and store it in the database table. The user defined type would contain the attributes. See an example in oracle database : oracle-base.com/articles/misc/object-views-and-nested-tables
– George Joseph
Nov 20 at 5:45
It is possible to create user defined type and store it in the database table. The user defined type would contain the attributes. See an example in oracle database : oracle-base.com/articles/misc/object-views-and-nested-tables
– George Joseph
Nov 20 at 5:45
You could use either XML or JSON and build SQL views to give you an easy query mechanism. In a way expand the json into relational view. It might not be the most performant. blogs.msdn.microsoft.com/sqlserverstorageengine/2015/12/09/….
– Akrion
Nov 20 at 5:46
You could use either XML or JSON and build SQL views to give you an easy query mechanism. In a way expand the json into relational view. It might not be the most performant. blogs.msdn.microsoft.com/sqlserverstorageengine/2015/12/09/….
– Akrion
Nov 20 at 5:46
@Akrion That's just for views, no? I still need to store the data as a string?
– LightStriker
Nov 20 at 5:54
@Akrion That's just for views, no? I still need to store the data as a string?
– LightStriker
Nov 20 at 5:54
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386770%2fhow-to-handle-multiple-user-save-games-of-a-rpg-in-sql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You have the option of storting json data into your database. Otherwise almost all of the database have support for storing xml.
– George Joseph
Nov 20 at 5:32
@GeorgeJoseph : I know, that's what I said I was doing. Is there a way to store Json other than by a "text" data type? But my goal was to not just dumb a huge string and go "That's the data" and be more "This cell holds the inventory, this cell holds the stats, this cell holds the quests". I assume this is impossible?
– LightStriker
Nov 20 at 5:36
It is possible to create user defined type and store it in the database table. The user defined type would contain the attributes. See an example in oracle database : oracle-base.com/articles/misc/object-views-and-nested-tables
– George Joseph
Nov 20 at 5:45
You could use either XML or JSON and build SQL views to give you an easy query mechanism. In a way expand the json into relational view. It might not be the most performant. blogs.msdn.microsoft.com/sqlserverstorageengine/2015/12/09/….
– Akrion
Nov 20 at 5:46
@Akrion That's just for views, no? I still need to store the data as a string?
– LightStriker
Nov 20 at 5:54