Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Database integration

Hi, I'm working on a project and I need to integrate some sort of a database.
I need it for mainly two purposes :
1. Authentication
2. Retrieving/Storing infos

I'd like to have some help cuz I'm actually not very familiar to databases. So, for example, which DBMS should I use? was thinking about MySQL but idk if it's possibile to implement it into UE4.
And then, most important, how to integrate it? Is there any tutorial out there? 'Cause I couldn't find any recent/working one. Thanks

Product Version: UE 4.19
more ▼

asked May 29 '18 at 02:53 PM in Using UE4

avatar image

13 1 2 6

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

The answer to this depends on several factors, the first of which is should the database be local to the project (i.e. installed on the users machine along with the project), or should it be hosted remotely (so many users are talking to the same database).

If you want it to be remote and you're not that familiar with database technology, you might want to use a service like gamesparks ( https://www.gamesparks.com/ and https://www.unrealengine.com/marketplace/gamesparks-sdk ). There are other services like this, so you might want to google. These can help you with authentication and data storage / retrieval with minimum effort, and they have resources / tutorials you can use.

If you want to install locally so the database is installed alongside the project, then I'd suggest looking at SQLite as it's significantly easier to manage in these situations, better for system resources and you won't run into conflicts if you try to install when someone already has something like MySQL installed on their system. Perhaps the best place to start with this is the market place: https://www.unrealengine.com/marketplace/assets?lang=&q=database

These are just my suggestions though. There are plenty of ways of tacking this problem but the above are good starting points.

Finally, if you are handling authentication yourself (on any type of database or authentication system), make sure you pay attention to proper security - you don't want to be responsible for data leaks!

more ▼

answered May 30 '18 at 10:54 PM

avatar image

1.1k 4 6 12

avatar image Ciliegino May 30 '18 at 11:42 PM

First of all I'd like to thank you for the reply. To clarify, my thought was to have two separate remote databases running on a dedicated machine. The First one would receive (i read about an https request) a request containing username and password and would send back to the asking client an account ID if there's a match or NULL if there's not. The second one would instead receive the current ID + some sort of an auth token and give access to the corresponding records (uses ID as a Key) so the gameserver can retrieve those with a query and send back to the client for gameplay uses. I would be able to code the queries but I font know how to access the database. I mean do I have to do it in c++? If so, is there any tutorial? Or is there any builtin integration?

avatar image phil_me_up May 31 '18 at 01:56 PM

If you're using a remote database, then you will almost certainly need to use https requests. The (objectively) nicest way of doing this is through RESTful APIs.

If you were setting all of this up from scratch, then you should have

  1. Your project

  2. Your database(s)

  3. A service layer that will sit on a publicly accessible server to handle the requests to/from your project to the database. You can write this in any language you want, but personally I prefer NodeJS, maybe with Express.

It is actually possible to bypass part 3 depending on the types of database you use. For example, if you use a service hosted on AWS (like DynamoDB), you can get direct access using their SDK: https://aws.amazon.com/sdk-for-cpp/ (SDK comes in loads of different languages, but if you want to communicate directly from the project I recommend C++). You should find some getting started guides for using Dynamo from C++ too, like this one: https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/examples-dynamodb.html

Before you look too much further, remember that DynamoDB is a NoSQL DB which might not be suitable for your needs. This link provides some info (Mongo is also a NoSQL DB): https://medium.com/xplenty-blog/the-sql-vs-nosql-difference-mysql-vs-mongodb-32c9980e67b2

If the AWS idea doesn't work for you, then you will need to use / write a C++ http request handler for for project, plus the service layer in whatever language you choose to host wherever you choose. Here's a nodeJS + Express example of a RESTful API to talk to a MongoDB: https://gist.github.com/iksose/9401758 (warning, I've not checked this for quality, but looks fine from a quick glace)

Again though, I suggest looking at something like GameSparks as this provides the database and service layer wrapped up in a nice package with added functionality for authentication etc and without having to worry about storing your data securely (database and dedicated machine). It has examples and a Unreal plugin too.

avatar image lastpoke Jul 27 '18 at 10:10 AM

What do you thing about own hosted mysql db? Worth it?

avatar image phil_me_up Jul 30 '18 at 12:05 PM

That depends on how comfortable you are setting it up, maintaining it and writing a API so it communicate with your game or other services. It also depends on if a relational database is the right choice over non-relational (mongo etc) as well as the expected traffic levels / costing etc.

There are a lot of factors so can't really say if it's worth it without knowing a lot more.

avatar image lastpoke Jul 30 '18 at 03:52 PM

Sure. Thanks!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question