Access2000 quick tutorial-1.6 define "primary key"
Access2000 quick tutorial-1.6 define "primary key"
The sixth definition of "primary key" can be used to create a large data database in Chinese Access 2000. Instead, the data distributed in different tables should be used as a "Database, you need to create a "primary key" for each table to create a relational database system. This system allows you to quickly search for data using queries, forms, and reports, and save information from different tables in combination. To do this, each table should contain the same one or a group of fields, which are unique identifiers of each record stored in the table, that is, the "primary key" of a table, which is usually created when a data table is created to save time. Therefore, this section is inserted here.
Access 2000 allows you to define three types of primary keys: automatic number, single field, and multi-field. Their features are described as follows.
1. Automatically numbered primary keys
In the previous operation, you must note that when you add a row of records to the table, the Chinese Access 2000 will always automatically set the number, even if you specify a different number, this software also allows you to set the automatic number field to automatically enter the serial number of consecutive numbers, so that the automatic number field is designated as the table's primary key, this is the easiest way to create a primary key, I believe you will remember that we did this before.
In fact, if no primary key is set before the new table is saved, Access 2000 in Chinese will ask whether to create a primary key. If the answer is "yes", the "auto-numbered primary key" will be created ". This primary key creation method can be applied to any Chinese Access 2000 table, but it is not so convenient in Chinese Visual FoxPro 6, it is difficult for beginners to master.
Note: After a table's primary key is specified, to ensure its uniqueness, Chinese Access 2000 prevents repeated values or Null from being entered in the primary key field. Null indicates that the field has no value or is unknown.
2. Single-field primary key
If some information-related tables have the same field and contain unique values, such as ID or part number, you can specify this field as the primary key. If the selected field has a duplicate value or a Null value, Access 2000 does not set its primary key. Therefore, you can run the "Search for duplicate items" query to find records containing duplicate data, edit and modify it.
Note: If the repeated items are still not easily eliminated by editing data, you can add an automatic number field and set it as the primary key or define a multi-field primary key, this is a useful operation technique.
3. Multi-field primary key
If you cannot guarantee that any single field contains a unique value, you can specify two or more fields as the primary key. This situation is most often seen in tables that are used to join two other tables in the many-to-many relationship. "Many-to-many relationship" is A concept that is difficult to understand in relational databases, but it is very practical. It shows that records in Table A can match many Row Records in table B, in addition, the records in Table B can also match many Row Records in table. The type of this link can only be implemented by defining the third table (called the join table). Its primary key contains two fields, that is, the external keys from the tables A and B. The many-to-many relationship actually uses two one-to-many relationships in the third table. For example, the "order" table and "product" table may have a many-to-many relationship, which is created through two one-to-multiple relationships in the "Order details" table.
Note: "One-to-multiple relationships" are the most common link types. In this relationship, A row of records in Table A can match many Row Records in Table B, but only one row of records in Table B can match one row in table. If A row in Table A matches only another row in Table B, this is A "one-to-one relationship ". Therefore, we can regard "one-to-one relationship" as a special case of "one-to-many relationship. Many-to-many relationships, one-to-one relationships, and one-to-many relationships are the basic concepts of application relational databases.
To specify or change the primary key, you can open the corresponding table in the "design" view and select one or more fields to be defined as the primary key from the "Row selector, click the "primary key" button in the "design view" toolbar. For details, see 9. To delete a primary key, you only need to select it in the row selector, and then click the "primary key" button in the "design view" toolbar, see 2.
9. Click this button.
If you do not see the design view toolbar on the screen, you cannot use the "primary key" button. To display it, click the "View" drop-down button in the "database view" toolbar and select the "design view" command from the drop-down menu, see 2 and 9-33.
0. Click the drop-down button.
1 select this command
2 Location of "Row selector"
Note: When selecting a field, you only need to click the corresponding box in "Row selector. To select multiple fields, press Ctrl and click their boxes in the row selector. For more information, see