The quality of the database layer design will greatly affect the performance of the application, the user experience is also closely related. What data should be avoided in the application development to enlarge the database.
1. Pictures, files, binary data, such as video, audio and other multimedia files are the most should not be put into the database.
Because: With the database more and more data, database backup and maintenance will become more and more difficult. Access to files runs through the multi-tier structure of the application, the application layer, the service layer, the database layer. The speed of database reading and writing is not up to the processing data of file system
The common practice is to store them in a large disk file system, while the database stores only their storage paths
2. Short Life Time Data
Use statistical data, measurement data, GPS positioning data, session data, any data that is useful to you in a short time, or that is constantly changing. If you find yourself using timed tasks to delete data from a table that is valid for only one hour, day, or weeks, you are not looking for the right way to do things. It might be better to use REDIS,MONGODBD
3. log file
Keeping the log data in the database looks good on the surface, and "Maybe I'll need to make complex inquiries about the data in the future." This is not a particularly bad practice, but if you store the log data and your product data in a database, it's very bad.
Maybe your log records are very conservative, and each Web request produces only one log. For every event in the entire site, this still produces a lot of database inserts, competing for the database resources your users need. So how much spare capacity do you have in your database to weigh up the amount of log data that you can do for complex queries, analytics, and logs that you put into the database?
You want to store the log data in the database, so you can use the database can do the advantage of complex queries to help you analyze the problem of the application, and do not want too much log data on the database system caused by too much pressure, perhaps the following is a good way, this is my recent learning SPRINGAOP and interceptor associated with the thought.
Using SPRINGAOP or interceptors combined with custom annotations, the classes and methods that you want to output logs to the database are annotated with annotations, which makes it easy to complete log filtering of target class method calls, combining APO and interceptors with the users you want to record, and the activity records of the roles in the database. (Perhaps the expression is not clear, this function will come soon ...) )