Click
Let's talk about the concept of horizontal table and vertical table. Let's take a look at the two figures below:
The first figure is a horizontal table, with a row representing an object record. This is the form of our traditional design table.
The second figure is a vertical table. Its row of records is used to indicate the ing between the attribute name and the attribute value of a student. For example, there are two attributes (name and gender ), in the vertical table, two records are used to represent a student.
We can see from the above that the benefit of a horizontal table is that it is clearly visible and clear, but there is a drawback. If you want to add a field to this table, you must recreate the table structure. In this case, you only need to add one record to the vertical table to add a field. The cost is far smaller than that of the horizontal table, but the data description of the vertical table is not very clear, in addition, there will be a large number of databases, and the advantages and disadvantages of both are that. Therefore, we should design a table structure that is not easy to change into a horizontal table, and design a table structure that is easy to change frequently as a vertical table.
In actual development, it is often necessary to convert the form of horizontal and vertical tables from each other. Here we paste the form of converting data from the vertical table to the horizontal table display.
?
1234 |
Selectstudent_no, max (decode (field_name, 'student _ name', field_value) asstudent_name, max (decode (field_name, 'student _ sex', field_value) asstudent_sex into metadata; |