Restructuring the data room charging system-view and restructuring the data room Charging System
During the first knock on the data center charging system, the database directly places these fields in a table based on the table and field used during the query. I have not considered three paradigms or anything. Because the contents in the table are dynamic when the card number is on or off the server, the card number will always be repeated, so even if the primary key is not set, this will happen directly. At that time, I didn't know what data redundancy was. After some professional training, I know that this is not the case. The database design follows the three paradigm.
The problem is that the database is designed based on the three paradigm. In this way, sometimes the fields to be queried are in two tables. What should I do? Now we need a new thing-view.
Views have also been learned before in database learning, but at that time they only looked at and didn't really get started. There will be a very high feeling in my heart. I had to use it this time, so I checked it and started to practice it. The discovery is actually very simple. Not as tall as you think.
The following describes the view.
There are two ways to create a view. The first method is to create a view in the database according to the database prompts. The second type is to directly write SQL statements to create them. Although I have learned view sentences before, but I have never practiced them manually, let's start with the first sentence.
First, right-click "View" and select "New View"
The "Add Table" window appears. Select the expected table and click "add"
The visualization tables are displayed. Check the fields you need. Then, corresponding SQL statements are generated below.
Click Save and name the view. You can also click execute to see the effect.
A view is a virtual table, so you can directly query the view as a table during query. In the created view, we can add conditions to the SQL statements generated below.
For example, I added a condition to set the value of the state FIELD IN THE T_OnOffLine table to False.
Summary:
What I learned in textbooks has never been practiced. I can only understand what I learned. If you encounter many problems, you can practice them and solve the problems. It will grow more. Practice.