Home > Software engineering > Excuse me, are on the server side, user data is stored in what is? Is a database?
Excuse me, are on the server side, user data is stored in what is? Is a database?
Time:10-21
I do a chat program, for example, the server will store all the user's information, such as name, gender, province, etc.,,,
These messages are generally, oneself do a structure array, the data stored in this structure, the server-side program exits, hard disk files saved to the server, the server starts up, the data read from disk again this structure in the array?
Or the user information stored in the database like mysql? Then use the mysql query language of database operations, add a record, query record?
Which is generally used?
CodePudding user response:
I now use the user data is stored in the structure of the array, name, age, gender, address and so on,,,
Server program exits, save the data to the hard disk, the server application starts, then loaded into the structure of data from hard disk file,
But that there is a drawback, that is, the structure of the C language data, each field is fixed, and I need a variable-length field, the variable-length field, the information of the users themselves, such as photos, some of the photos is very small, a few K, some pictures is very big, a few hundred K, if each user to the space of a few hundred K, could do a lot of waste,
And like mysql database, the most attractive thing is that can be stored longer fields, such as variable-length binary data, it is very useful to me, I'm prepared to give each user a personal weibo, weibo contents of each of the users themselves, is stored in their own variable-length field, while some users according to not tweeting, so, some needs a few M to 10 M of space, some don't need, word length field is not completed,
Excuse me, in this case, the mysql database is used to store user information a little better?
CodePudding user response:
Using a database to store user information and benefits, is the ability to change the length of the field, or add or remove a field, and does not affect the content,
And use the structure of the C language array to hold, it is impossible to do this, unless the new structure and old structure is put together, the data with the program reads from the old structure, deposit to the new structure, the word is not so convenient database operations,
I want to ask is: in general, the service side is saved user information in the database? Is it in your own design in the array?
CodePudding user response:
CodePudding user response:
Generally, text information database, save hard disk images, image path what written into the database,
Concurrent with no database, but it looks like you should not need,