We have learned how to send and receive data through the previous lessons, but it is not enough to understand how to send and receive data, we need to save the message information of these users for future query. Therefore, we will learn about the database design in this lesson.
Objective:
In order to be familiar with the basic design method of the database, we also store the user's message information for the next step.
Software requirements:
Install Access in the Microsoft Offfice series (read: ocses', of course, you cannot read the plug here, because it is difficult to express the sound in Chinese characters. Use this plug for the time being, I am afraid that you will be confused when adding a phonetic symbol. In short, you can understand that the sound is between the plug and the Sun.) or install Ms-SQL, however, our preliminary explanation mainly focuses on access.
Method:
First, open access and click "new" in "file" to create an empty database. It is recommended that you store the database in the directory where our program is stored for future convenience, at the same time, give the database a name called db. mdb
You can see the following view:
Click the "design" button to open the data table design window.
In the field name column, first enter the id. For the data type, select "auto Number". This field will be the unique identifier of the message content in the future; automatic numbering of this type of data does not require our intervention. When we store a new data in the database, this value is automatically accumulated, this ensures that each record of the stored data has a unique id number, and this number is never repeated.
In the field name column of the second row, we enter title. In the Data Type of the title column, we select "text". Then we can see that on the "General" tab, the default field size is 50. Here we can add it as appropriate and change it to 100. Of course, it will not be a problem if it is not modified. The newly added title will be used to store the title of our message.
In the field name column of the third row, we enter message, in the data type in the message column, the I-bucket of the inegis ammonia cylinder will be used to store our message content.
The final effect is as follows:
Finally, click the Save button in the upper left corner to create a database named guestbook. You may be required to define a primary key while saving the database. Click No.
In this way, we have designed our database.
Key points:
This lesson involves three data types:
1. Automatic ID
2. Text
3. Remarks
Let's take a closer look at these three types:
Automatic serial number: it can be used as a unique identifier of data because it does not repeat. In the future, we can determine this message by using this unique value.
Text Type: it can be used to store text or numbers. Its maximum length is limited. This is why we just changed the 50 to 100, the adjustment just now is actually to adjust his maximum length limit.
Remark type: it can store any data with no limit on the length. It is often used as a storage for large articles. Its disadvantage is that the length is not limited, therefore, the processing speed for retrieving this field by a program is not too fast. Therefore, it is recommended to use text instead of remarks for data that is not short or small.
Now this lesson has been explained. The following is the database I designed. In the next lesson, we will explain how to store the obtained message content in the database.
Attachment: My Data Warehouse .rar