Office
 

Microsoft Access 2010 : Designing a Database

1/30/2012 5:35:01 PM
The most basic object in a database is the table in which you store your data. You might be tempted to jam every type of data you want to store into a single table, but that’s hardly ever the right way to design tables in a database. The following guidelines will help you create efficient tables.



1. One Table per Object

The first rule in creating database tables is to ensure that every table stores data about one type of object, whether that object is a person, a product, or an order. As an example, consider the Suppliers table from the Northwind sample database.

This table has a field for everything you want to know about a supplier, with nothing extra. Consider this alternative design, which adds fields to describe the supplier’s products.

Aside from repeated data, deleting the record representing the last product from a supplier removes all information about that supplier from your database. Rather than risk losing that information, it is much more efficient to create one table for the suppliers and another for the products.



2. Give Every Table a Primary Key

Another important consideration in creating a table is to assign a primary key. This field contains a value that sets a record apart from all other records in the table. In the Northwind database’s Shippers table, that role is filled by the ID field.

It’s also possible to create a primary key made up of more than one field, as in the table shown in the following illustration. (Please note that this table is just a sample; it isn’t in the Northwind database.)

The ProductID field identifies the product and the SupplierID field identifies the product’s supplier. Because you can order the same product from more than one supplier, both the ProductID and SupplierID fields are needed to distinguish a record from all other records in the table.



3. Include Foreign Keys

A final thing you can do to make your tables more efficient is to include primary key fields from other tables, as with the SupplierIDs field in the Products table.

When a primary key from one table is stored in another table, it is called a foreign key. You can use foreign keys to create relationships between tables.

 
Others
 
- Microsoft Outlook 2010 : Sending Text Messages from Outlook & Sending Mobile Alerts from Outlook
- Microsoft Outlook 2010 : Using Alerts and Mobile Features - Setting Up a Text Messaging Service
- Microsoft OneNote 2010 : Upgrading from a Previous Version
- Microsoft Word 2010 : Customizing Word - Changing Advanced Document Properties & Changing Research Options
- Microsoft Word 2010 : Customizing Word - Setting Advanced General Options & Setting Compatibility Options
- Microsoft Project 2010 : Setting Up Resources - Adjusting Working Time for Individual Resources
- Microsoft Project 2010 : Setting Up Resources - Entering Resource Pay Rates
- Microsoft Visio 2010 : Displaying the issues for the current selection
- Microsoft Visio 2010 : Displaying the rule for a selected issue
- Accessing PowerPoint on the Web and Mobile Devices (part 2) - Setting SkyDrive Permissions
- Accessing PowerPoint on the Web and Mobile Devices (part 1) - Setting Up SkyDrive
- Microsoft PowerPoint 2010 : Managing Themes
- Microsoft Excel 2010 : Printing in Excel - Adjusting Page Margins & Inserting Page Breaks
- Microsoft Excel 2010 : Setting the Print Area
- Microsoft Outlook 2010 : Setting Up Mobile Alerts for Important Messages
- Microsoft Outlook 2010 : Setting Up Calendar Alerts
- Microsoft OneNote 2010 : Searching for Stray Notes (part 2)
- Microsoft OneNote 2010 : Searching for Stray Notes (part 1)
- Microsoft PowerPoint 2010 : Managing Slide Masters
- Microsoft PowerPoint 2010 : Customizing and Creating Layouts
 
 
Most View
 
- Adobe Flash Professional CS5 : Manipulating Symbols in 3D Space (part 1) - Controlling the camera view: Perspective and vanishing point
- Adobe Flash Professional CS5 : Manipulating Symbols in 3D Space (part 2) - Transforming symbols with the 3D Rotation tool
- Mobile Web Apps : Loading Pages (part 3) - Going Backwards
- Microsoft Dynamics AX 2009 : Design and Implementation Patterns (part 1) - Class-Level Patterns
- Introducing the iPhone SDK (part 5) - Programming Paradigms
- Beginning Android 3 : Set Up the Emulator
- Microsoft Excel 2010 : Analyzing Worksheet Data - Adding Data Validation to a Worksheet
- Microsoft Dynamic CRM 2011 : Resolving a Service Request Case
- Accessing PowerPoint on the Web and Mobile Devices (part 1) - Setting Up SkyDrive
- Microsoft Excel 2010 : Using Print Preview