Problem
Queries in data operations are extremely important and frequently used. The concept of view in the MySQL database is very similar to the query in the Microsoft Access Small relational database (second-level exam focus). The presence of views greatly reduces the number of data tables created, and there are more advanced techniques to use. This paper introduces a small problem to be noticed when using the view in MySQL database on the BeX5 platform based on the starting technology to generate ontology in reverse.
The table in MySQL database corresponds to the "physical table" concept in the development of the BeX5 platform, but in order to enhance the flexibility of the data layer in software development (the entity structure of the software requirements phase is not determined by the minute, and sometimes needs to be adjusted constantly), the platform introduces the concept of ontology.
In the actual development, it is necessary to create the ontology first, and then generate the physical table by the ontology. However, it is sometimes necessary to reverse-generate the ontology from a physical table in the case where the physical table already exists.
The importance of a view (equivalent to a select query for access) is mentioned above, but to use view technology in BEX5 platform development, it is necessary to deal with ontology. This requires that the ontology be generated in reverse by the view.
First, creating a view in MySQL is relatively straightforward, as in the following example:
CREATE VIEW v as Mv_homepage_person_viewselect a.fid,a.flegcode,a.fcasename,a.fbegindate,a.fwho,b.fpersonname, C.fenddatefrom mv_leginfo a,mv_person2 b,mv_penalty2 cwhere A.flegcode=b.flegcode and B.fLegCode=c.fLegCode
Once saved, the above view generates a physical table in MySQL (which is consistent with Access's build table query).
Second, in the platform can be created by the view of the table above the platform development requirements of the ontology reverse generation.
In this process, many students who first use this feature tend to ignore the selection of field A.fid when creating the above view, and this field is acting as the primary key in the default platform-generated ontology, and its default value is GUID (). If you do not select this field, the action that references this ontology when creating the UI2-side. w file must have an error (the hint is roughly the missing FID field)!
Solutions
Through the above analysis, the solution to the above problems is very simple. However, there are two minor issues to note:
(1) Be sure to select the FID field of a table when creating the view above (it may not necessarily be this field, as long as the field until the primary key is theoretically possible--but the following GUID () function is no longer suitable, and needs to be expressed flexibly).
(2) After the reverse generation of the ontology, be sure to modify the "primary key relationship", similar to:
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/9A/6D/wKiom1lVwmPRFNMNAACsfutSDCw669.jpg-wh_500x0-wm_ 3-wmp_4-s_4141451032.jpg "title=" capture. JPG "alt=" Wkiom1lvwmprfnmnaacsfutsdcw669.jpg-wh_50 "/>
Click on "PRIMARY key relationship" above to select the primary key you chose when you created the view in the dialog box that pops up. Of course, it is highly recommended to use the default FID as the primary key. This requires that the FID field be provided in the child table of the generated view (this is supported by the platform by default).
The rest of the operation will not be mentioned later. Although the child table generated by the view is "dead", it can be easily modified by creating the view's CREATE VIEW statement, which allows you to create such temporary tables as needed at any time, so the application of the view is high-frequency on the database side. Correspondingly, the operation of generating the ontology from the view on the BeX5 platform is also high frequency.
This article is from the "Green Peak" blog, please make sure to keep this source http://zhuxianzhong.blog.51cto.com/157061/1943409
A small problem with MySQL view in BeX5 development