TLE

Embed Size (px)

Citation preview

  • 1. Primary keysA table can only have one primary key. A primary key is a field or setof fields that:Has a unique value for each recordIs indexedIdentifies the record It uniquely defines a relationship within a database. It is a field or a combination of two or more fields. The value in theprimary key field for each record uniquely identifies that record.Specify Primary Keys

2. Foreign keysA foreign key, simply stated, is another tables primary key. The valuesin a foreign key field match values in the primary key, indicating thatthe two records are related for example, a customer and an orderthat she has placed. Unlike primary keys:A table can have more than one foreign key.A foreign key does not necessarily have unique values.Specify Foreign Keys 3. A foreign key cannot reliably identify a particular record. For example, youcannot always tell which record you are viewing from the Orders table bylooking at the Customer ID.You create a foreign key when you use the Lookup Wizard to create a field.Specify Foreign Keys 4. For example, each customer might havemany orders. Rather than store thecustomers address in each record in theOrders table, you store that informationonce in a record in the Customers table. Tocombine the customer information with therest of the information about the order, youcreate a relationship between the twotables, by using key fields.You can add the primary key from one table to another table tocreate a relationship between them. In the other table, it is called aforeign key.For example, suppose you use the primary key of the Customerstable in the Orders table. In the Orders table it is a foreign key. 5. Legend:1 Primary Keys2 Foreign Keys 6. Add records directly to atable in datasheet viewA table open in Datasheet view resembles an Excel worksheet, and youcan type or paste data into one or more fields the equivalent of a cell ina worksheet. 7. Remember these facts as you proceed. You do not need to explicitly save your data. Access commits yourchanges to the table when you move the cursor to a new field in thesame row, or when you move the cursor to another row. By default, the fields in an Access database are set to accept a specifictype of data, such as text or numbers. You must enter the type of datathat the field is set to accept. If you dont, Access displays an errormessage: A field may have an input mask applied. An input mask is a set of literaland placeholder characters that force you to enter data in a specificformat.