The three-level structure of the database system refers to that the database system consists of three levels: mode, external mode, and internal mode.
(1) The mode is also called the logical mode or conceptual mode. It is the logical structure and feature description of all data in the database and is the public data view of all users.
Mode is actually a logical view of database data. A database has only one mode. When defining a schema, you must not only define the logical structure of the data, but also define the relationships between data and data-related security and integrity requirements.
(2) The external mode is also called the user mode. It is the logical structure and feature description of local data that can be viewed and used by database users. It is the data view of database users, is the logical representation of data related to an application. The external mode is usually a subset of the mode. A database can have multiple external modes. Applications are dealing with external models. External mode is a powerful measure to ensure database security. Each user can only view and access the data in the corresponding external mode. The remaining data in the database is invisible to them.
(3) The internal mode is also called the storage mode. A database has only one internal mode. It is the description of the physical structure and storage method of data, and the representation of data in the database. For example, the record storage method is sequential structure storage or B-tree structure storage, the way the index is organized, whether the data is compressed, whether it is encrypted, and how the data storage record structure is defined.
2. The secondary image function and Data independence of the database in order to realize the connection and conversion between the three abstract layers of the database internally, the database management system provides two layers of images between the three modes.
(1) The external mode/mode image corresponds to any number of external modes in the same mode. For each external mode, the database system has an external mode/mode image, which defines the correspondence between the external mode and the mode. When the mode changes, the database administrator changes the external mode/mode image to keep the external mode unchanged. Applications are written based on the external data mode, so that the application does not need to be modified, ensuring the logical independence between the data and the program.
(2) There is only one mode and only one internal mode in the mode/internal mode image database. Therefore, the mode/internal mode image is unique, it defines the correspondence between the global logical structure of the database and the storage structure. When the storage structure of the database changes, the database administrator changes the mode/internal mode image so that the mode remains unchanged and the application does not need to be modified. Ensures the physical independence of data and programs.
In the three-level mode structure of a database, the global logical structure is the center and key of the database. It is independent from other layers of the database. Therefore, the logical structure of the database should be determined first when the database schema is involved.