Whenever coming up with new tables in MS Access or redesigning existing tables, expert MS Access consultants want to make sure that every table should possess a column, or two or three columns, that uniquely identifies every record stored within the MS Access database table. Some Access database designers use unique identification numbers, such as social security numbers, employee Id numbers or product serial numbers. MS Access database designers, along with alternative database designers for different sorts of databases call this the table’s primary key. MS Access uses primary key fields to index, i.e., immediately group together information from multiple tables and marshal the data as one.
If your database table already includes a distinctive identifier, like social security number for a dental patient, or product SKU that uniquely identifies each product in your hardware catalog, you’ll be able to use that identifier as the table’s primary key. However, you must be fully sure these values in this primary key column can never be the same for an additional record record. You can not have duplicate values for database primary keys. As an example, do not use town names as a primary key, because names are seldom unique in a very database’s record set. You’ll easily have 2 cities with the identical name in the same table, like Sandpoint, Idaho and Sandpoint, Alaska.
Primary keys should never be empty, null or repeat. In brief, primary keys must continuously have distinctive values. If a column’s value can ever be unknown (a missing value) or possibly changed at some future purpose, this column ought to never be used as a primary key, or part of a composite primary key.
Always opt for primary keys whose values will never change. When you have got an MS Access database that contains a lot of than one table, it is attainable and often practical that the table’s primary key will be used as a reference for other tables. If the primary key changes, the change should also be applied everywhere the key is referenced in the opposite tables. Designing database tables where primary keys do not amendment reduces the prospect that the primary key might not coincide with different dependent tables referencing it.
One preferred technique used by most Microsoft Access consulting is to use an arbitrary value, like a guid, or sequential number. These arbitrary distinctive numbers are very helpful when used as primary keys. As an example, you would possibly assign each fishing lodge invoice a unique invoice number. The invoice number’s sole purpose is to uniquely delineate a fishing lodge’s invoice. Once assigned, it never changes and has no reason to change.
Many Microsoft Access consulting directly take into account employing a column that has the AutoNumber data sort, in spite of whether or not there may be a social security number, a distinctive product SKU number or another unique identifier.
When your MS Access database tables use the AutoNumber data type, Access by design assigns a worth for you. Such identifiers don’t have any value and are inconsequential other than they are the primary key. The AutoNumber contains no relevant info regarding the record. Since there is no immediate relation to the first key and this information outside of the record set, AutoNumber identifiers are ideal for primary keys as a result of they do not change. Primary keys containing relevant info or facts about a row, such as postal codes, telephone numbers or a client addresses, are more seemingly to change because the factual info would possibly change throughout the life of the information in your database.
There are occasions when two or more fields logically makeup an MS Access database table’s primary key. For instance, for an Alaska hunting and fishing lodge, a BookingDetails table stores details for Bookings would use two columns as a primary key: BookingId and LodgeServiceId. When primary keys consist of additional than one column, they are typically known as composite keys by database professionals.
Getting your MS Access database design “right” is typically a matter of preference and no two people can design the database excactly the same. There are rules that make data access and maintainability less complicated, and these rules are learned in formal settings. One ought to attempt to continually make the database scalable and maintainable.
Related posts:
RSS Feed
Twitter
February 26th, 2010
gooddevi
Posted in
Tags: ![Validate my RSS feed [Valid RSS]](valid-rss.png)







