Хелпикс

Главная

Контакты

Случайная статья





PRIMARY KEY. More tables, data types



PRIMARY KEY

Each row in the table is called a record. A well-designed database always has a field (or fields) that holds the unique identifier for each record. This field(s) is called the Primary Key.

  • Often this identifier is a number, but it could be text or a combination of text and a number
  • The important characteristic is that it is unique meaning that each record has a different one
  • In the table you just created, the Primary Key field has the name ID

NOTE: In Excel, you have rows & columns, in Access you have records & fields

6. To save your table, do one of the usual things (i. e., click on the Save icon in the upper left-hand corner or click on the Office button and choose Save or right-click on the tab labeled Table1). Give it the name tablePerformers

Once it's saved, the name will appear in the list on the left side of the screen:

 

Next, you will create two more tables

 

More tables, data types

Next you will be creating two more tables, tableVenues and tableEvents. Feel free to figure out how to make this on your own (then jump to step 5), or follow the directions below.

tableVenue will look this:

and tableEvents will look like this (we will add data to this table later):

1. Again, click on the Create tab and then the Table icon to create a new table.

2. Add 2 fields ( Venue and Address ) by double-clicking on Add New Field, typing the name and hitting the Enter key. Then fill in the data so it looks like this:

For interest you must include a " Home Cinema" venue with your home address.

3. Save this table with the name tableVenues

4. Create a third table with three fields (in addition to the ID field), called PerformanceDate, PerformerID and VenueID

Every field has a data type.

The ID that Access creates has the data type AutoNumber. It's called AutoNumber because it is autmatically filled with a number whenever you create a new record.

Other fields that you create are given the data type Text, but you can change that, and we will:

5. Be sure the Home tab is selected (see the image below) and click on the View drop-down. You'll probably see 4 view options. We have been viewing our tables in Datasheet View, but now we want to look at them in Design View so click on the Design View icon. ( PivotTable View and PivotChart View allow you to build special table and chart views, but we won't learn about those in this class).

In this view (shown in the image below), you can't see the data you entered, but you can see information about each field. Notice the little key symbol next to the ID field. This indicates that this field is the Primary Key.

Notice that the data type for the ID field is AutoNumber as described above.

The data type for PerformerID and VenueID is Text.

6. Change the data type for these two fields to Number:

7. Save the table as tableEvents

 

 



  

© helpiks.su При использовании или копировании материалов прямая ссылка на сайт обязательна.