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

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: Content Search - UE Marketplace

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!

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?

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: AWS SDK for C++ (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: Amazon DynamoDB examples using the AWS SDK for C++ - AWS SDK for C++

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: Creating a REST API using Node.js, Express, and MongoDB · GitHub (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.

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

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.

Sure. Thanks!

:slight_smile: Прпфесори много :slight_smile: