• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
beebs1

Database Persistence

9 posts in this topic

Hiya,

Are there any standard patterns for database object persistance I can look up?

Thanks :)
-1

Share this post


Link to post
Share on other sites
[quote name='Telios' timestamp='1329156086' post='4912667']
Hiya,

Are there any standard patterns for database object persistance I can look up?

Thanks [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]

By 'object' do you mean literally serializing an object (state and all) to the database? I think in general that's a bad idea. But then again, what is the context of your problem?
1

Share this post


Link to post
Share on other sites
[quote name='Telios' timestamp='1329156086' post='4912667']
Are there any standard patterns for database object persistance I can look up?
[/quote]
Yes, many. So many, in fact, that people can get advanced degrees on the subject.

Is there some specific need you are trying to solve?
1

Share this post


Link to post
Share on other sites
Thanks for the answers [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I'm looking for a way to retrieve and persist database entites (as classes) without making SQL calls directly in the application logic. For some classes, I'd also like to cache them.

I'm thinking along the lines of a 'Manager' or 'Store' for each entity type, which performs the SQL calls and can cache the objects in an internal map of { ID -> Object } as needed.

As an example:
[code]
class OnlineProfileEntity
{
unsigned int getAccountD() const;

void setAuthTicket(const Ticket&...);
const Ticket& getTicket() const;
// etc...
};

class OnlineProfileStore
{
public:

// does the actual DB access.
OnlineProfileStore(DatabasePool& databasePool);

// get from the cache, otherwise query the database
smart_ptr<OnlineProfileEntity> getProfileByID(unsigned int id);
};
[/code]

I was just interested in any common patterns there might be...

Thanks again [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
The Repository is the common pattern name given to the wrapper around building/saving your entities from/to the data access tier.
1

Share this post


Link to post
Share on other sites
You mean something like [url="http://en.wikipedia.org/wiki/Object-relational_mapping"]this[/url]?
1

Share this post


Link to post
Share on other sites
The reality is that it is easier to just define your database tables with the data you need to store, and stop trying to store "objects". If you store all the data stored by the object is not hard to create a constructor that takes that data and recreat the object at any time.
1

Share this post


Link to post
Share on other sites
Thanks for the replies.

[quote name='meeshoo' timestamp='1329227219' post='4912961']
You mean something like [url="http://en.wikipedia.org/wiki/Object-relational_mapping"]this[/url]?
[/quote]

Not quite, I think - I'm just looking for something that will let me refactor the SQL queries from the class that parses network packets from the TCP buffer...

[quote name='TheTroll' timestamp='1329240420' post='4913032']
The reality is that it is easier to just define your database tables with the data you need to store, and stop trying to store "objects". If you store all the data stored by the object is not hard to create a constructor that takes that data and recreat the object at any time.
[/quote]

True - I'm not trying to do this exactly. More something that sits between the application logic and the database code, and can return entities from the database with some form of caching.
0

Share this post


Link to post
Share on other sites
[quote name='Telios' timestamp='1329242987' post='4913058']
True - I'm not trying to do this exactly. More something that sits between the application logic and the database code, and can return entities from the database with some form of caching.
[/quote]
If caching objects you load from the database to speed up later requests to "load" them again is useful, maybe other parts of your application are being too forgetful with the objects they load; references should be retained properly instead of loading the same objects repeatedly.

Ask yourself if generic caching in the database access layer is really the best approach; it might be appropriate or good enough, but maybe what you need is transaction processing, without persistent objects, or smarter and specialized data structures to manage persistent objects in useful ways that go beyond the basic load-store-cache functionality of the underlying ORM.
0

Share this post


Link to post
Share on other sites
[quote name='TheTroll' timestamp='1329240420' post='4913032']
The reality is that it is easier to just define your database tables with the data you need to store, and stop trying to store "objects". If you store all the data stored by the object is not hard to create a constructor that takes that data and recreat the object at any time.
[/quote]


Or of course, you can do the opposite and not use SQL. The NoSQL movement, even the [url="http://en.wikipedia.org/wiki/NoSQL#Object_database"]object database[/url] are rising in popularity. If you are trying to store non-tabular data, it makes no sense to use a table based database.

[url="http://en.wikipedia.org/wiki/MongoDB"]MongoDB[/url] is certainly one of the most popular, with some pretty serious support behind it, but there are a dozen or so viable options. MongoDB works with Key/Value pairing and might be a much better fit.


That said, everyone and their dog are getting into this space, Amazon, Google, Oracle, Microsoft ( sorta ), etc...
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0