Chapter 2. Building Smarter Tables
In the previous chapter, you learned how to dish out databases and pop tables into them without breaking a sweat. However, thereâs bad news. The tables youâve been creating so far arenât up to snuff.
Most significantly, you havenât explicitly told Access what type of information you intend to store in each field of your table. A database treats text, numbers, dates, and other types of information differently. If you store numeric information in a field that expects text, then you canât do calculations later on (like find the average value of your bobblehead dolls), and you canât catch mistakes (like a bobblehead with a price value of âfourscore and twentyâ).
To prevent problems like these, you need to define the data type of each field in your table. This is the central task youâll tackle in this chapter. Once youâve mastered data types, youâre ready to consider some of the finer points of database design.
Understanding Data Types
All dataâs not created equal. Consider the Dolls table you created in Chapter 1 (Section 1.2.3). Its fields actually contain several different types of information:
Text. The Character and Manufacturer fields.
Numbers. The ID and PurchasePrice fields.
Dates. The DateAcquired field.
You may naturally assume that the PurchasePrice field always includes numeric content, and the DateAcquired field always includes something that can be interpreted as a date. But if you havenât set the data types correctly, ...
Get Access 2007: The Missing Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.