This has been the best explanation (verbally and visually) of how databases work in general. Love the fact you show the primary/foreign keys in the tables. I have been studying database engineering the last 5 months and JUST yesterday remembered that games use db's as well. This was perfect for me to see it being layed out. Thank you!
Thanks for the positive feedback :-) And yeah, in my opinion a lot more games could make greater use of databases, for more clever and interesting gameplay features.
Good to hear I don't need a online server for my Singelplayer game, will go through your next videos to see how I can implement SQL in my game. Because some of the examples you gave really work with my game.
I come back to this video a lot to debate it and Im just not sure if i have a need for it. The case you described at the end is exactly what i need, but I can do the same thing with the asset manager and data assets and some instanced structs. Theres a few drawbacks and limitations, but im avoiding the dependency and working with much more in-engine documentation. DLC and add-on data is also much easier and idk. I guess i just dont get it. I need examples of how the implementation actually works to see a benefit because thats what it comes down to. Making data assets is easy peasy. But how do i add characters to the db? How do i query? Would this even work with instanced structs and data like that? If so it returns to the previous question. Theres no hashing for instanced structs(at least in 5.1-5.4 idk if its in 5.5) so putting them into maps isnt possible and thats a challenge. Id have to loop through data assets and query data to see if any have something that matches. I dont know if this solves that, too many questions not enough time to test it. Thank you for thr video though
Ok, well the first thing I would point out, which is often the case with ANYTHING in computing; You can absolutely do things in a different way. Forgetting games for a second and speaking generally: Anything you can do with an SQL database, you can implement somehow yourself in some alternative way. The issue is more about if you *should* , and how much *work* it would take, etc. vs. the *benefits* of using SQL for a specific task. So, lets focus on the benefits of an SQL db, just to point out what it gives you. - Storage: Obviously, you can store data there, which you can do in other ways too. But I would argue that a good SQL db helps keep your data more organised. - Relational Data: With SQL you are very easily able to relate one kind of 'thing' with another. In the sense of an RPG game for example, you can have a table for the NonPlayerCharacters, and you can have a table for SecretSocieties, then you can have a table called NPCSecretSocieties - which relates which societies each character is affiliated with. This goes for 'static' game data which you set up at design time, as well as 'dynamic' game data (the player's save game if you will) at runtime. Extending that previous example, we could easily track which secret societies a player was a member of, and more than that, what their standing is with ANY society, even the ones they are not a member of (The guild of mages hates me after my character murdered all their herb-pickers that time I got drunk and went on a rampage, for instance.) - Integrity of Data: This is a really compelling one. With a well designed db, using *referential integrity*, you get more than just a storage for data, and the ability to link data - you get a guarantee of sorts that nonsense data cant go into the database in the first place. Referential integrity means - I cant delete a secret society, if NPCs are still a member of it, for example. (Or I could have it automatically delete them, if i prefer) This can be a real time saver in terms of validation and testing for many 'data driven' games. Think of the number of times you play a game with some sort of *quest* system, only to find certain quests get 'broken' and cant be completed, because, simply put, the data underlying the quest is in a state which the developer never really considered it could be in. A SQL db with referential integrity would prevent *many* of those situations from happening (obviously there can be other causes too, but its a start, ok?) - Querying Data: And of course, getting the data back out of a database is kinda useful. SQL gives you a fairly easy to learn, and (if the underlying db structure and engine are good) very performant way of retrieving data. And you are not limited to just grabbing data like you would be with arrays in C++ for example. With SQL you will often find you have a whole bunch of different tables, and you can make a query which connects across all of them, grabs whatever bits of data you want from each, and returns it in one go. You simply don't have anything like this unless you use an SQL database. I TRIED with Unreal when I first started, to use their datatables feature. It seemed ok, I could import from CSV files, etc, etc. But it does NOTHING for you. want to know all the NPCs who are members of a SecretSociety AND live in any Town currently owned by Queen FickleFanny? With C++ you likely need to trawl through all the towns in a town datatable, find the ids for the one you want, then use those TownIDs to trawl through the NPC table to find the NPCs flagged as living in those towns, AND THEN, go through each of those NPCs, looking in another datatable to find which are members of what secret societies (or you might have that data in an array in the NPC datatable, whatever, the point is -> PAIN IN THE ASS, you gotta code it all in C++ [or BPs even worse!] and its messy) In SQL you would have a single query which would get you what you need, in a performant manner, and is very easy to test and edit. Also, as games get bigger and more complicated, it is no longer easy to see when (using unreal's datatables) if the data in one table is valid in terms of another table - for example, if each NPC in your datatable had the aforementioned list of SecretSociety Ids they were a member of, there is no way to tell if those Ids are even valid. (Nothing is stopping them having ID=12 even if there is no such secret society) So, in summary... SQL *can* save you time, *will* offer you better structure, *can* protect your data from mistakes, and *is* performant enough to use in real-time games. If your project is a clone of brickbat, or pac-man, then yeah... you totally don't need SQL though. 😉
@ggamedev Thank you for the breakdown! Some of those issues you brought up that SQL solves here highlights some things I hadn't considered. I'm gonna have to take a deeper look on how this integrates with data assets and the asset manager, but it might help I'm just gonna have to experiment
The data will be saved whenever the insert update or delete queries are run on the database. When you’re writing the code for the game you’d likely have functions and methods that are querying the database for these records and modifying them as the game is running. When you exit the game all that information should still be stored there
Hi there. I certainly can go down that road, ifs on my todo list, and if I get enough positive feedback for it I definately will; Client/Server databases were my bread and butter for a long time ;-) However, as I mention in the video, and other comments I posted elsewhere, the reason I started this series with SQLite, is because its NOT client/server, and its totally free; there is nothing for you to pay for - no server requirement, no set up fees, no monthly bandwidth charges - because there is no server involved. For much of the 'SQL goodness' I am trying to expose to game devs, SQLite does everything that is needed. Of course, once you get on to multiplayer/online/persistant worlds, that sort of thing, then server databases are absolutely the way to go. Certainly a problem for many game devs is *MONEY* though, especially when they are just starting out - they work solo, or in very small groups, trying to find people to work on their games as a team, and it's difficult. The SQL you can learn making a game using SQLite is very much directly transferrable to those client/server database systems, but without the hastle or cost of needing them while you are learning.
Hello How can we contact you to develop such things in UE5? I don't know if you are available. Anyway, Ty a lot for your explanations because in my games this is exactly what I was looking for (I am from web development industry). And it seems that is not common to work with databases ty man !
If you have anything you want to discuss, the easiest way is to jump on the discord server discord.gg/jjy2aJ3hj9 You can post any questions, or IM me if you have something specific you need to discuss directly.
Great Explanation. I found this video because i was looking for a way to Store Player Value in a Database on UE5. For example : Item Unlocked? If yes, how many Items does the player have? A good example is : a player plays on a dedicated server that handles the NPCs, Trader interaction, Player Position etc. But things like Player Level, EXP, Playtime, Items in Inventory etc. should all be saved somewhere else. Do i use a SQL database for this too? And if yes, whats a reliable way to prevent data loss, backups every few minutes to another rented SQL server?
Generally, for the multi player games, a dedicated server (or a server farm, or 'cloud' servers) are used, especially if there are a huge number of players. But that doesn't need to be so in your case; It really depends on how many players you will have and how much total data you will want to store, etc. You can certainly start out with a sqlite database on the dedicated game server. It will usually perform faster than a client/server database because its right there. Not saying the client/server model is bad - it gives a tonne of extra benefits also. If using sqlite - the database is just a file. you can copy it, clone it, move it around, however you want. So you could have some mechanism which takes a copy every 10 minutes or whatever, and stores it on another drive, or even to another machine entirely. If using a client/server database, most will have built in mechanisms to perform backups - however there is often 'some' performance hit while this is happening, although it may not actually be noticeable.
In fact, with a database behind it, you could even make a template project for such games, reusing pretty much the same thing, but having new content in the database for each story + new assets in the unreal project 👍
You had me worried for a moment there - had to google who that is, and found some Aussie Evangelist bloke. I found the correct guy eventually though (oracle stuff), and honestly... I'm guessing you are not English, are you? Because apart from the fact Tim and myself both are, we don't really sound that similar. (He sounds a bit more 'northern' than I do for one thing) But hey, whatever.... wouldn't mind a few of his subscribers! lol Kinda weird we both have the databases thing though...
@@ggamedev ha i am UK based actually, in all fairness i watched a few more of your uploads and other ones don't sound as much but this one does for sure 🙂 I had to do some research to make sure you weren't really Tim moonlighting 😄
...They are non gender specific panties. They may even be VIRTUAL, covering situations where PANTY_TYPE == COMMANDO But I can confirm, as a programmer, they are absolutely BINARY (64 bit) 😉
That was painfull to watch. You could have cut at leat 10mn of fat, speaking about your imaginary gameplay and get to talk on how to setup the database.
I think maybe you missed the point there: if there was 10 mins of 'fat', then it was 'all' fat. 😄 The purpose of the video was more to try and 'advertise' database use as an option to game developers, because surprisingly many never realise or consider it for their projects. It wasn't really about specifics, that was intended for other videos EDIT: Also, I don't think you are allowed to say my video has 'fat' any more... I think its now more acceptable to say 'voluptuous content'
유익한 정보 감사합니다.
This has been the best explanation (verbally and visually) of how databases work in general. Love the fact you show the primary/foreign keys in the tables. I have been studying database engineering the last 5 months and JUST yesterday remembered that games use db's as well. This was perfect for me to see it being layed out. Thank you!
Thanks for the positive feedback :-)
And yeah, in my opinion a lot more games could make greater use of databases, for more clever and interesting gameplay features.
Wow! I love the comprehensive introduction and going into complex scenarios that SQL databases can be used for.
Thank you very much, kind of you to say so. 🙂
Dude, this is great, and I really love the way that you explain things! Thanks!
Great video. Some video game UIs are paper thin covers for a database backend. Star Ocean II and Xenoblade X and a lot of other JRPs come to mind.
Good to hear I don't need a online server for my Singelplayer game, will go through your next videos to see how I can implement SQL in my game. Because some of the examples you gave really work with my game.
thank you. i use RDB in webservices and have had a tough time thinking about how i should implement my games' schemas. this playlist is helpful
Hell yeah let's make a Morrowind-like bro !! :) great vid
Now that's what I'm taking about! :-)
you got to few subscribers bro
Thanks for the positive comment 🙂
Slowly those subscriber numbers go up, which means RUclips lets more people know about my vids.
I come back to this video a lot to debate it and Im just not sure if i have a need for it.
The case you described at the end is exactly what i need, but I can do the same thing with the asset manager and data assets and some instanced structs. Theres a few drawbacks and limitations, but im avoiding the dependency and working with much more in-engine documentation. DLC and add-on data is also much easier and idk.
I guess i just dont get it. I need examples of how the implementation actually works to see a benefit because thats what it comes down to. Making data assets is easy peasy. But how do i add characters to the db? How do i query? Would this even work with instanced structs and data like that?
If so it returns to the previous question. Theres no hashing for instanced structs(at least in 5.1-5.4 idk if its in 5.5) so putting them into maps isnt possible and thats a challenge. Id have to loop through data assets and query data to see if any have something that matches. I dont know if this solves that, too many questions not enough time to test it.
Thank you for thr video though
Ok, well the first thing I would point out, which is often the case with ANYTHING in computing;
You can absolutely do things in a different way.
Forgetting games for a second and speaking generally:
Anything you can do with an SQL database, you can implement somehow yourself in some alternative way.
The issue is more about if you *should* , and how much *work* it would take, etc. vs. the *benefits* of using SQL for a specific task.
So, lets focus on the benefits of an SQL db, just to point out what it gives you.
- Storage: Obviously, you can store data there, which you can do in other ways too. But I would argue that a good SQL db helps keep your data more organised.
- Relational Data: With SQL you are very easily able to relate one kind of 'thing' with another. In the sense of an RPG game for example, you can have a table for the NonPlayerCharacters, and you can have a table for SecretSocieties, then you can have a table called NPCSecretSocieties - which relates which societies each character is affiliated with.
This goes for 'static' game data which you set up at design time, as well as 'dynamic' game data (the player's save game if you will) at runtime. Extending that previous example, we could easily track which secret societies a player was a member of, and more than that, what their standing is with ANY society, even the ones they are not a member of
(The guild of mages hates me after my character murdered all their herb-pickers that time I got drunk and went on a rampage, for instance.)
- Integrity of Data: This is a really compelling one. With a well designed db, using *referential integrity*, you get more than just a storage for data, and the ability to link data - you get a guarantee of sorts that nonsense data cant go into the database in the first place.
Referential integrity means - I cant delete a secret society, if NPCs are still a member of it, for example. (Or I could have it automatically delete them, if i prefer)
This can be a real time saver in terms of validation and testing for many 'data driven' games.
Think of the number of times you play a game with some sort of *quest* system, only to find certain quests get 'broken' and cant be completed, because, simply put, the data underlying the quest is in a state which the developer never really considered it could be in. A SQL db with referential integrity would prevent *many* of those situations from happening
(obviously there can be other causes too, but its a start, ok?)
- Querying Data: And of course, getting the data back out of a database is kinda useful. SQL gives you a fairly easy to learn, and (if the underlying db structure and engine are good) very performant way of retrieving data. And you are not limited to just grabbing data like you would be with arrays in C++ for example.
With SQL you will often find you have a whole bunch of different tables, and you can make a query which connects across all of them, grabs whatever bits of data you want from each, and returns it in one go.
You simply don't have anything like this unless you use an SQL database.
I TRIED with Unreal when I first started, to use their datatables feature. It seemed ok, I could import from CSV files, etc, etc.
But it does NOTHING for you. want to know all the NPCs who are members of a SecretSociety AND live in any Town currently owned by Queen FickleFanny?
With C++ you likely need to trawl through all the towns in a town datatable, find the ids for the one you want, then use those TownIDs to trawl through the NPC table to find the NPCs flagged as living in those towns, AND THEN, go through each of those NPCs, looking in another datatable to find which are members of what secret societies (or you might have that data in an array in the NPC datatable, whatever, the point is -> PAIN IN THE ASS, you gotta code it all in C++ [or BPs even worse!] and its messy)
In SQL you would have a single query which would get you what you need, in a performant manner, and is very easy to test and edit.
Also, as games get bigger and more complicated, it is no longer easy to see when (using unreal's datatables) if the data in one table is valid in terms of another table - for example, if each NPC in your datatable had the aforementioned list of SecretSociety Ids they were a member of, there is no way to tell if those Ids are even valid. (Nothing is stopping them having ID=12 even if there is no such secret society)
So, in summary...
SQL *can* save you time, *will* offer you better structure, *can* protect your data from mistakes, and *is* performant enough to use in real-time games.
If your project is a clone of brickbat, or pac-man, then yeah... you totally don't need SQL though. 😉
@ggamedev Thank you for the breakdown! Some of those issues you brought up that SQL solves here highlights some things I hadn't considered. I'm gonna have to take a deeper look on how this integrates with data assets and the asset manager, but it might help I'm just gonna have to experiment
Will this set of videos cover how to save data to the server when a persistent game instance is shut down?
The data will be saved whenever the insert update or delete queries are run on the database. When you’re writing the code for the game you’d likely have functions and methods that are querying the database for these records and modifying them as the game is running. When you exit the game all that information should still be stored there
Wonderful explanation 👍....IDK who are those 5 dislikes
Thanks.
Probably people who dislike my delivery, or sense of humour... because, i mean... databases + games: what's not to like? 😆
Can u please add tutorials for c++ and my sql?
Hi there. I certainly can go down that road, ifs on my todo list, and if I get enough positive feedback for it I definately will; Client/Server databases were my bread and butter for a long time ;-)
However, as I mention in the video, and other comments I posted elsewhere, the reason I started this series with SQLite, is because its NOT client/server, and its totally free; there is nothing for you to pay for - no server requirement, no set up fees, no monthly bandwidth charges - because there is no server involved.
For much of the 'SQL goodness' I am trying to expose to game devs, SQLite does everything that is needed.
Of course, once you get on to multiplayer/online/persistant worlds, that sort of thing, then server databases are absolutely the way to go.
Certainly a problem for many game devs is *MONEY* though, especially when they are just starting out - they work solo, or in very small groups, trying to find people to work on their games as a team, and it's difficult. The SQL you can learn making a game using SQLite is very much directly transferrable to those client/server database systems, but without the hastle or cost of needing them while you are learning.
Hello
How can we contact you to develop such things in UE5? I don't know if you are available. Anyway, Ty a lot for your explanations because in my games this is exactly what I was looking for (I am from web development industry). And it seems that is not common to work with databases
ty man !
If you have anything you want to discuss, the easiest way is to jump on the discord server discord.gg/jjy2aJ3hj9
You can post any questions, or IM me if you have something specific you need to discuss directly.
Great Explanation.
I found this video because i was looking for a way to Store Player Value in a Database on UE5.
For example :
Item Unlocked?
If yes, how many Items does the player have?
A good example is : a player plays on a dedicated server that handles the NPCs, Trader interaction, Player Position etc.
But things like Player Level, EXP, Playtime, Items in Inventory etc. should all be saved somewhere else.
Do i use a SQL database for this too? And if yes, whats a reliable way to prevent data loss, backups every few minutes to another rented SQL server?
Generally, for the multi player games, a dedicated server (or a server farm, or 'cloud' servers) are used, especially if there are a huge number of players.
But that doesn't need to be so in your case; It really depends on how many players you will have and how much total data you will want to store, etc.
You can certainly start out with a sqlite database on the dedicated game server. It will usually perform faster than a client/server database because its right there.
Not saying the client/server model is bad - it gives a tonne of extra benefits also.
If using sqlite - the database is just a file. you can copy it, clone it, move it around, however you want. So you could have some mechanism which takes a copy every 10 minutes or whatever, and stores it on another drive, or even to another machine entirely.
If using a client/server database, most will have built in mechanisms to perform backups - however there is often 'some' performance hit while this is happening, although it may not actually be noticeable.
YOU ROCK!
Very kind of you :-)
Wow now many things i thought is impossible in anime and manhwa RPGs isn't
In fact, with a database behind it, you could even make a template project for such games, reusing pretty much the same thing, but having new content in the database for each story + new assets in the unreal project 👍
Good
useful
'Useful' was exactly what I was aiming for. Thank you :-)
This guy sounds like Tim Hall! (Oracle Base)
You had me worried for a moment there - had to google who that is, and found some Aussie Evangelist bloke.
I found the correct guy eventually though (oracle stuff), and honestly... I'm guessing you are not English, are you?
Because apart from the fact Tim and myself both are, we don't really sound that similar. (He sounds a bit more 'northern' than I do for one thing)
But hey, whatever.... wouldn't mind a few of his subscribers! lol
Kinda weird we both have the databases thing though...
@@ggamedev ha i am UK based actually, in all fairness i watched a few more of your uploads and other ones don't sound as much but this one does for sure 🙂 I had to do some research to make sure you weren't really Tim moonlighting 😄
Panties in a bunch? As I guy, that's a tall order
...They are non gender specific panties.
They may even be VIRTUAL, covering situations where PANTY_TYPE == COMMANDO
But I can confirm, as a programmer, they are absolutely BINARY (64 bit) 😉
Speciesist, not Racist.
thanks for the vidya
You are most welcome :-)
That was painfull to watch. You could have cut at leat 10mn of fat, speaking about your imaginary gameplay and get to talk on how to setup the database.
I think maybe you missed the point there: if there was 10 mins of 'fat', then it was 'all' fat. 😄
The purpose of the video was more to try and 'advertise' database use as an option to game developers, because surprisingly many never realise or consider it for their projects. It wasn't really about specifics, that was intended for other videos
EDIT: Also, I don't think you are allowed to say my video has 'fat' any more...
I think its now more acceptable to say 'voluptuous content'