Two independences of two-level image in three-level database mode

1. The three-level model structure of the database system:

The three-level model structure of the database system means that the database system is composed of three levels of external mode, mode and internal mode, as shown in the figure:


①schema:

       The mode is also called the logical mode, which is a description of the logical structure and characteristics of all data in the database, and is a common data view of all users. It is the middle layer of the database system pattern structure, and it does not involve the physical storage details of the data. The right has nothing to do with the specific application, the application development tools used, and the high-level programming language.

       Schema is actually a logical view of database data. There is only one mode for a database. The database model is based on a certain data model and agrees to comprehensively consider the needs of all users and organically combine these needs into a logical whole. When defining a pattern, not only must you define the logical structure of the data, such as which data items constitute the data record, the names, types, and value ranges of the data items; but also to define the connections between the data, define the security and integrity of the data Sexual requirements.

       The database management system provides a schema data definition language (schema DDL) to strictly define schemas.

②External schema:

       The external mode is also called subschema or user mode. It is a description of the logical structure and characteristics of local data that can be seen and used by fixed-line telephones (including application programmers and end users) of the database. It is a data view of database users. It is a logical representation of data related to an application.

       Foreign patterns are usually a subset of patterns. A database can have multiple external modes. Since it is a data view of each user, if different users have differences in application requirements, the way they view data, and the requirements for data confidentiality, the external mode description is different. Even for the same data in the mode, the structure, type, length, security level, etc. of the external mode can be different. On the other hand, the same external mode can also be used by multiple application systems of a user, but one application can only use one external mode.

       External mode is a powerful measure to ensure database security. Each user can only see and access the data in the corresponding external mode, and the rest of the data in the database is not visible.

③Internal schema:

       The internal mode is also called storage schema (storage schema), a database has only one internal mode. It is a description of the physical storage and storage method of data, and the organization of data within the database. For example, whether the record is stored in heap or in ascending (descending) order of certain attribute value (s), or clustered according to attribute value; how the index is organized, whether it is B + tree index or hash index ; Whether the data is compressed and stored, whether it is encrypted; what are the storage record structure of the data, such as fixed-length structure or variable-length structure, a record can not be stored across physical pages; and so on.

2. The secondary image function and data independence in the database:

       The three-level model of the database system is the three abstract levels of data. It leaves the specific ancestors of the data to the database management system to enable users to process the data logically and abstractly, without having to care about the specific representation of the data in the computer Storage method. In order to realize the connection and conversion of these three abstract levels within the system, the database management system provides two layers of images between these three levels of modes: external mode / mode image and mode / external mode image.

       The formal two-layer image ensures that the data in the database system can have a high degree of logical independence and physical independence.

① External mode / mode image:

       The mode describes the global logical structure of the data, and the external mode describes the local logical structure of the data. There can be any number of external modes corresponding to the same mode. For each external mode, the database system will have an external mode / mode image, which defines the correspondence between the external mode and the mode. These image definitions are usually included in the description of the respective external mode.

When the mode changes (such as adding new relationships, new attributes, changing the data type of attributes, etc.), the database administrator changes the images of each external mode / mode accordingly to keep the external mode unchanged. The application program is written according to the external mode of the data, so that the application program does not need to be modified, and the logical independence of the data and the program is ensured, or the logical independence of the data for short.

2. Mode / internal mode image:

The database has only one mode and only one internal mode, so the mode / internal mode image is unique, which defines the correspondence between the global logical structure of the data and the storage structure. For example, explain how logical records and fields are represented internally. The image definition is usually included in the pattern description. When the storage structure of the database changes (for example, another storage structure is selected) , the database administrator makes corresponding changes to the mode / internal mode image, which can keep the mode unchanged, so that the application does not have to change. The physical independence between the data and the program is guaranteed, referred to as the physical independence of the data.






Published 8 original articles · Likes2 · Visits 480

1. The three-level model structure of the database system:

The three-level model structure of the database system means that the database system is composed of three levels of external mode, mode and internal mode, as shown in the figure:


①schema:

       The mode is also called the logical mode, which is a description of the logical structure and characteristics of all data in the database, and is a common data view of all users. It is the middle layer of the database system pattern structure, and it does not involve the physical storage details of the data. The right has nothing to do with the specific application, the application development tools used, and the high-level programming language.

       Schema is actually a logical view of database data. There is only one mode for a database. The database model is based on a certain data model and agrees to comprehensively consider the needs of all users and organically combine these needs into a logical whole. When defining a pattern, not only must you define the logical structure of the data, such as which data items constitute the data record, the names, types, and value ranges of the data items; but also to define the connections between the data, define the security and integrity of the data Sexual requirements.

       The database management system provides a schema data definition language (schema DDL) to strictly define schemas.

②External schema:

       外模式也称子模式(subschema)或用户模式,它是数据库用固话(包括应用程序员和最终用户)能够看见和使用的局部数据的逻辑结构和特征的描述,是数据库用户的数据视图,是与某一应用有关的数据的逻辑表示。

       外模式通常是模式的子集。一个数据库可以有多个外模式。由于它是各个用户的数据视图,如果不同的用户在应用需求、看待数据的方式、对数据保密的要求等方面存在差异,则其外模式描述就是不同的。即使对模式中同一数据,在外模式的结构、类型、长度、保密等级等都可以不同。另一方面,同一外模式也可以为某一用户的多个应用系统所使用,但一个应用程序只能使用一个外模式。

       外模式是保证数据库安全性的一个有力措施。每个用户只能看见和访问所对应的外模式中的数据,数据库中的其余数据是不可见的。

③内模式(internal schema):

       内模式也称存储模式(storage schema),一个数据库只有一个内模式。它是数据物理存储和存储方式的描述,是数据在数据库内部的组织方式。例如,记录的存储方式是堆存储还是按照某个(些)属性值的升(降)序存储,或按照属性值聚簇(cluster)存储;索引按照什么方式组织,是B+树索引还是hash索引;数据是否压缩存储,是否加密;数据的存储记录结构有何规定,如定长结构还是变长结构,一个记录不能跨物理页存储;等等。

2.数据库中的二级映像功能与数据独立性:

       数据库系统的三级模式是数据的三个抽象级别,它把数据的具体祖冲之留给数据库管理系统管理,使用户能逻辑地、抽象地处理数据,而不必关心数据在计算机中的具体表示方式和存储方式。为了能够在系统内部实现这三个抽象层次的联系和转换,数据库管理系统在这三级模式之间提供了两层映像:外模式/模式映像和模式/外模式映像。

       正式这两层映像保证了数据库系统中的数据能够具有较高的逻辑独立性和物理独立性。

①外模式/模式映像:

       模式描述的是数据的全局逻辑结构,外模式描述的是数据的局部逻辑结构。对应于同一个模式可以有任意多个外模式。对于每一个外模式,数据库系统都会有一个外模式/模式映像,它定义了该外模式和模式之间的对应关系。这些映像定义通常包含在各自外模式的描述中。

当模式改变时(例如增加新的关系、新的属性、改变属性的数据类型等),由数据库管理员对各个外模式/模式的映像作相应改变,可以使外模式保持不变。应用程序是根据数据的外模式编写的,从而应用程序不用修改,保证了数据与程序的逻辑独立性,简称数据的逻辑独立性。

2.模式/内模式映像:

数据库只有一个模式,也只有一个内模式,所以模式/内模式映像是唯一的,它定义了数据全局逻辑结构与存储结构之间的对应关系。例如,说明逻辑记录和字段在内部是如何表示的。该映像定义通常包含在模式描述中。当数据库的存储结构改变时(例如选用了另一种存储结构),由数据库管理员对模式/内模式映像作相应改变,可以使模式保持不变,从而应用程序也不必改变。保证了数据与程序之间的物理独立性,简称数据的物理独立性。






Guess you like

Origin blog.csdn.net/qq_42003546/article/details/103931571