Although application servers can do much more than communicate with data sources, that functionality is, by far, most commonly used to create dynamic Web sites. A data source is any application or file that stores structured data. It's the structure that's important in a data source; given a known structure, data can be extracted by other applications and processes. Relational databases, XML, spreadsheets, and even text files can serve as data sources. Most often, however, data-driven Web sites extract their information from the output of a data source application. Data source applications are either file-based or server-based. File-based data source applications, such as Microsoft Access, save their data in computer files that you can copy, transfer, or rename. Server-based data source applications, such as Microsoft SQL Server and MySQL, maintain the data in a dedicated server. Although file-based data sources tend to be easier to develop for, server-based data sources are more robust and better suited for Web work. Some developers work in both worlds by developing in Access and transferring their work to SQL Server through a process called upsizing, which is discussed later in this chapter. Note You might be more familiar with the term database rather than the more generic term data source. A database is one type of data source. Both file-based and server-based data sources use the table as a basic building block. A data source table is composed of a series of rows and columns, much like a spreadsheet. Each column in a table makes up a data source field, and each row is a separate data source record. For example, in the Recipes data source, you'll find an employee table that looks, in part, like this:
This example has five records, each with four columns or fields: EmployeeID, EmployeeFirst, EmployeeLast, and EmployeeEmail. Each column is a particular data type; here, all but EmployeeID are text fields. EmployeeID only accepts numeric data. Making sure that your data field has the proper data type is the first step in designing a data source schema or structure; other data types include boolean (yes or no), currency, and date/time. Because a data source holds data in a structured manner, the data is easy to manipulate. The example table shows records in the order in which they were entered; we can easily sort the table to show it in alphabetical order by the last name field, EmployeeLast:
In addition to sorting, another important concept in manipulating data sources is filtering. Data sources are typically filtered to retrieve only the significant records. For example, if you wanted to show only those employees whose last name begins with an S, your resulting table would show this:
A filtered subset of a table is called a recordset, and the directions for creating a recordset are referred to as a query. Later in this chapter, we'll discuss the syntax for creating queries using SQL. |