Chapter 2 Retrieving Data from a Database In

Tables are the backbone for any database. Each table comprises columns and rows designating attributes of the data you want to store. The best way to envision a table consisting of columns and rows is to think of a table as a grid in which the columns and rows of the grid correspond to the various attributes for that table. For example, the ORDER table might contain rows for each order and columns for the date the order was entered, who entered the order, the customer for which the order was placed, the promised ship date of the order, and so on. The specific products contained in a customer order might be in another related table called ORDER DETAILS. Each column has a data type associated with it that describes what type of information is stored in the column. If the column is to contain a number, the data type is a numeric data type. Data types can be numeric, text, decimal, currency, notes, and so on. Keying In on Your Data For any given table in the database, you have at least one attribute that uniquely identifies it. (There might be an order number column for this purpose, for example, conveniently called OrderID.) In the world of database management, you call such a column (or set of columns) whose value uniquely identifies every row in a table a primary key. An example of a primary key for a PERSON table is an American s Social Security number because this number is unique for every person in the United States. Having a primary key is great because when you later have to manipulate all the data you ve stored, you can access each record uniquely by referring to the value of its primary key. Any primary key you choose to set up for a table has to meet the following common-sense requirements: No two rows can have the same primary key value. Every row must have a primary key value assigned to it. The column containing the primary key value cannot be modified or updated. Primary key values can never be reused. In your database travels, you are likely to encounter the concept of a foreign key. Don t despair or think that you suddenly have to learn some foreign language in order to crack a secret code. A foreign key is simply a primary key for one table that is kept in another table to make it easier to join the two tables to query information from two related tables. 30 Part I: Just the Basics

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.