2,3 Xác định một khóa và các chỉ số chỉ số chính được sử dụng để cải thiện hiệu suất khi truy vấn dữ liệu, chẳng hạn như tìm kiếm trên các lĩnh vực và phân loại thông tin. | Define a Primary Key and Other Indexes Indexes are used to improve performance when querying data such as searching on fields and sorting information. The primary key is an index that ensures that you have at least one unique value in each record such as a Customer ID. This How-To discusses what the best candidates are for primary keys as well as how to create them and other indexes. You have created a base table and have even entered data into it. How do you make sure that you have a way of finding specific records LastName and FirstName fields won t work because you can have duplicates of those. You also want to make sure that when you search on fields you get the best possible performance from SQL Server. Indexes can be created to help performance. How do you define a primary key field to make sure that you have unique records and can create other indexes as well Technique Within the Server Explorer you can use a field such as a Social Security Number and make that into a primary key field. By making a field the primary key field you will need to make that field unique and prohibit null values there. The alternative to a current unique field is to create a field that is automatically incremented called an identity field. This identity field can also be set as the primary key field again so that the record is made unique. The primary key field will also be indexed. Besides creating the special primary key field you can create indexes that perform two main functions Performance. Used to increase performance when the column is used for search criteria and sorting and when you re loading ranges of records. Constraints. This is one of the jobs that the primary key field performsconstraining the data that users can put into the table. Note When creating indexes for performance purposes only take care that you don t go overboard. Although indexes help performance when searching and sorting they can hurt performance when adding and updating data. This is mainly true