Practical exercise | Create a view in Navicat 16

To normalize database tables, redundant columns in high-level tables are often extracted into separate subtables. This usually happens because some fields have a one-to-many relationship with the parent entity.  For example, please refer to the following model generated using  Navicat Data Modeler :

Assessments were originally part of the ups table, but this resulted in data redundancy as multiple vehicles could be assessed in one visit. Therefore, it would be wise to remove the fields for vehicles from the ups table and put them in their own table.

The downside of normalizing to third normal form (3NF) is that you end up with a lot of ID fields in the main table. As a database practitioner looking at tables, it can be difficult to know which entity each ID column points to. As an example, look at the ups table in the model diagram above, and notice that CSR, customer, and vehicle are all reduced to numeric IDs that don't help identify the underlying entities:

This part has to do with auto-incrementing IDs and normalization, but anyway, by creating views we can make the data easier to read. A database view is a subset of the database that is based on queries run on one or more database tables. Database views are saved in the database as named queries and can be used to save frequently used complex queries.

In  Navicat 16  , we can select "File" -> "New" -> "View..." from the main menu to create a new view:

This will add a new view tab.

The next step is to add the SQL statement that will generate the view fields:

If you need any help writing your statement, the tab toolbar has buttons for Preview, Explain, View Builder, and Beautify SQL.

Assuming we don't want to wait for the view to be created to see the result, we can click the "Preview" button to see the result immediately:

The ID column now contains more descriptive and meaningful text data.

Under the tab button, there are three more tabs - Definition, Advanced and SQL Preview. The Advanced tab contains additional options such as algorithm, definer, security, and checking options, while the SQL Preview shows the generated CREATE VIEW statement:

The new view is named "Untitled" until saved. A dialog box appears when saving, where the view name can be specified:

After saving, the new view will be added to the left navigation pane and can be called at any time:

Conclusion on creating views in Navicat 16

In today's article, we learned about database views and how to make a view that links a table to related tables via an ID field to help identify records of that table. In today's article, we learned about database views and how to make a view that links a table to related tables via an ID field to help identify records of that table. Welcome to learn about the 14-day free trial and experience the database management development tool  Navicat Premium  or the professional database model tool  Navicat Data Modeler  to realize this function.

Past review 

  1. Recruit Navicat Monitor 3.0 monitoring tool experience officer |
  2. Nanny level tutorial | Navicat manual backup and automatic backup
  3. Navicat 16 officially supports OceanBase full-line database products
  4. Navicat 16 will soon support Redis
  5. Try Navicat 16 for free
  6. Navicat's 20-year development history | Founded in Hong Kong, China in 1999
  7. The role of WHERE 1=1 in the SQL statement
  8. Calculate percentage of total rows in SQL
  9. The interactive gift event is in progress | The prize is Navicat Premium worth 819 yuan
  10. Fake websites cause multiple security risks | Official solemn statement: Do not buy or download Navicat software from unofficial channels

Guess you like

Origin blog.csdn.net/weixin_53935287/article/details/131071361