Now it is really difficult to find a complete time. On and off, there will be a great leap in thinking. In this case, I may be able to find more things from my mind. Next, let's continue with yesterday's topic...
Persistent Layer
I subdivided this layer into three levels: persistent objects, data interfaces, and databases.
1. Database
The Analysis and Design of databases are the expertise of DBAs. I know that we should follow three paradigms as much as possible. For business execution efficiency, sometimes it may even violate the paradigm. It is very important to design and draw an ER diagram. It is also helpful to find an excellent ER model. After you drag the data table and fields to complete the design, you can directly deploy it to the database!
2. Persistent Object
Based on the designed database to create objects, my approach is very simple, that is, to create an object for each table, the object attribute is the fields in the database, objects are added, deleted, modified, and queried. For the relationship between 1 A and n B, a B object set is added to the attribute of a. This B object set is generally inherited from list or map, used to store N bits. In this way, the database is clearly described.
3. Data interfaces
This part mainly establishes the connection between objects and databases. There are many specific ways to connect to the database. You can easily use a universal connection pool. We need to write a parsing interface to convert the Persistent object into the corresponding content of each table in the database, and then encapsulate the data read from the database into the Persistent Object.
In addition, this resolution interface can also be applied in the presentation layer. After a persistent object is processed, it must be converted into a table that can be viewed as HTML before it comes to the page, the interface implementation method here may be slightly different from the database interface implementation method mentioned above.