P0-P-172: Part 68: SQL Server Conncetion, C# Server
I have created a C# program that is capable of connecting to my existing mySQL database and performing all of the usual functions, execution queries, etc. This was relatively simple.
I have decided to use my previous method of integrating mySQL in this project too. I will have a separate C# server where the mySQL code will reside, and the Unity clients will communicate with that server using custom code which I will write.
There are several advantages to this. The main one would be security, it is never, ever, a good idea to allow a client program or machine to directly send SQL commands to a database, because if the client program gets hacked, the hacker can send whatever SQL queries they want to the database.
Secondly, there are licensing restrictions with mySQL that prevent it from being distributed to client machines without a licence fee being paid. Keeping the mySQL code on the server (which would be private) prevents having to redistribute the code, which makes mySQL free.
Thirdly, having a separate game server allows precise control over what kind of queries are going to and coming from the database, this is very important for optimisation and performance, as well as security.
I have created a simple socket server that connects Unity to my C# SQL server. Currently it only supports a single client, so it will need improvements.
