My understanding of data dictionary

1. Concept

There are two forms of data dictionary

1. Put the attribute code of the main body into a separate table, instead of putting it together with the main body, only the code of the attribute is kept in the main body. Here the number of attributes is constant, while the number of attribute values ​​can be changed.

2. Use a table to put all the attribute information with the same structure, the different values ​​of different attributes are uniformly coded, the "type" is used to distinguish different attributes, and the list of attribute codes is kept in the main body. In this way, the number of attributes owned by the subject is variable.

The second type of data dictionary is more abstract, higher level, and more general and versatile than the first.

 

2. Example description

A staff table, including: name, nationality, credentials, and education.

Nationalities include: Chinese, American, Japanese

Documents include: ID card, driver's license

Educational qualifications include: PhD, master, bachelor, junior college

 

Three, the first form of data dictionary

The ultimate goal is the employee table, and each attribute of each employee has fixed content. For example, the nationality of an employee can only be: China, the United States, and Japan. Therefore, each attribute is designed as a table, and the ID in each attribute table can be referenced in the employee table.

1. A form of nationality

Nationality ID

Nationality name

001

China

002

United States

003

Japan

 

2. A document form

ID

the name of your ID

001

ID card

002

driver license

 

3. A list of academic qualifications

Education ID

Education name

001

PhD

002

master's degree

003

Undergraduate

004

Junior college

 

4. Staff table

Staff ID

Name

Country of Citizenship

Certificate

Education

2001

Zhang San

001

001

002

2002

Li Si

003

002

004

 

Advantages: Each attribute table can be dynamically modified.

Disadvantages: When querying employees, a lot of tables are required to perform a joint table query. If there are many attributes, it is not convenient to expand.

 

Two, the second form of data dictionary

Observing the above attributes, there is a commonality: there are only 2 fields, the first field is the identification, and the second field is the content.

So, you can put these attributes in a table:

1. Attribute table

Logo

classification

content

001

contry

China

002

contry

United States

003

contry

Japan

101

identify

ID card

102

identify

driver license

201

education

PhD

202

education

master's degree

203

education

Undergraduate

304

education

Junior college

 

2. Staff table

Staff ID

Name

Country of Citizenship

Certificate

Education

2001

Zhang San

001

101

202

2002

Li Si

003

102

304

 

Advantages: There is only one attribute table.

If you want to query all nationalities, just query "category"="contry" in the attribute table.

 

Third, the above employee table has another shortcoming, that is, the attribute field of each employee is fixed.

If: one employee may have many attributes and another employee has few attributes, there is a waste of space.

Therefore, you can split the employee table into two tables:

1. Staff table

Staff ID

Name

2001

Zhang San

2002

Li Si

 

2. Attribute table

Staff ID

Attribute identification

2001

001

2001

101

2001

202

2002

003

2002

102

2002

304

The employee ID is 2001 and has 3 attributes, namely: 001, 101, 202

职员ID为2002的,拥有3个属性,分别是:003,102,304

这样的话,每个职员可以拥有不同数量的属性。

 

 

Guess you like

Origin blog.csdn.net/u012296253/article/details/109798658