The most common type of database in use with Web applications is a relational database management system (RDBMS), such as Microsoft Access or MySQL. An RDBMS stores data in a collection of tables that have a defined relationship with one another. The tables provide a structured way to store information. The columns (or fields) in a table contain data about a single category. The rows (or records) in a table contain one element of data in each category. The easiest way to understand database tables is to look at some examples. Figure 4.1 shows a table we'll call the ClassRoster table, created in Microsoft Access 2003. This table has five fieldsStudentID, First Name, Last Name, CourseID, and InstructorIDand four records. Figure 4.1. A database table organizes information in columns (fields) and rows (records).
If you use the ClassRoster table as a data source, you can access data from any or all records and fields in this table. For example, you could create a class roster for the instructor that lists all students by first and last names for the MA130 course. You could also add a Grade field to the Class-Roster table, and create a dynamic Web page that enables the instructor to enter grades online and add this information to the table in the database. Figure 4.2 shows another table, the Instructors table, located in the same database as the ClassRoster table. This table has three fieldsInstructorID, First Name, and Last Nameand consists of four records. As you'll see in a moment, the data in these two tables is relationalthat is, the data in one table is connected to the data in the other. Figure 4.2. A database may contain several tables of related information.
Databases use primary keys to identify a specific and unique record in a database table. In the Class-Roster table, the StudentID field is the primary key. Each StudentID is unique and identifies a specific record (row) in the table. In the Instruc-tors table, the InstructorID field is the primary key. Databases use relationships among the data in the tables to define the interactions between pieces of information. There are three types of relationships:
Primary keys and relationships are essential elements in database design; they are used to decide what tables you need to create and what information should be included in each table. For more information on database design, see the appendix "Beginner's Guide to Databases" in Dreamweaver Help (F1). Once your database is built, you can request information from it using a database query. You use the results of these queries to add dynamic content to your pages. |