Database
Concept
The principle of interactivity is clearly seen in databases and their use online. The idea of a database is simple: where plain websites are entirely static (they display the same content every time you look at them, unless the have been manually updated), data-driven websites is one of the things that makes a website dynamic, with new, fresh, content. Essentially, what displays on the page is determined in some part by what's in the database. (Greenspan)
You might be familiar with how a basic webpage works. HTML code that is already written is sent to your browser. Your browser translates this code into a webpage which you can see. With a webpage that uses a database, all or some of the HTML is generated by the data in database, adding an extra step to the process, but meaning that you'll see new data fresh from the database. When the maintainer of the website wants to update a page, he or she manually or automatically (usually the latter) changes the data in the database. The next time you view the page, you'll interact with new data.
How is this interactivity, you might ask. Simple: the website provides you with fresh data from the database, and gives you the opportunity to change the database in most cases (such as when you rank an article or video). Rather than just presenting one, stale page of HTML, it presents a fresh page of generated HTML that represents real-time data. When you perform an action, the data will often update, and, the information displayed. (Chappel)
Examples
Most moderately complex websites use some form of a database. A simple example is an e-commerce site. If you view an item for sale on an e-commerce site, the website will check to make sure the item is in stock before the present a "Checkout" button. If the item isn't in stock, it won't let you buy it, but will rather display a message informing you of this. Notice how sites like Amazon.com and Newegg.com do this the next time your purchase something. Also, most user interactivity connects back to a database at some point. All of those comments and stories from users on Digg, tags on a Flickr photo, or articles on Wikipedia are stored in a database of some sort.
Using Databases
There are many types of databases. In this getting started guide, we’ll outline what you need to set up a popular free database so that other technologies (such as ASP.NET or PHP) can interact with it.
A popular free choice for webmasters is a type of database called MySQL. You can download the free version of MySQL here. It runs on both Windows and Linux. We also recommend that you download a reference manual here. Once you have the database downloaded and installed, you need to configure your web technology to link it to your website (for example, using ASP.NET or PHP). This is typically done with something known as a “connection string.” Essentially, this is a piece of data that specifies where your database is, what data you wish to access, and what username and password, if any, you are using. Connection strings vary greatly from database to database, but mostly only in syntax—the above concepts are universal across databases and technologies. For more on virtually every type of connection string, see an excellent free resourcehere.
As with ASP.NET or PHP, databases are generally server-side, meaning that they run on your web server. If you want your database to be part of a website visible to the world (as opposed to just an experimental site on your computer), you’ll need to set your database up with your web host. The procedure varies from host to host, but generally you’ll need to upload or configure some files and change your connection string to reflect the new location of your database.
It is also worth covering how data is stored in a database, and what technologies are often used to retrieve it. Almost all data is stored in tables, with columns, called “fields,” and rows, called “records.” A sample table might be named “People” with fields of “First_Name,” “Last_Name,” and “Date_of_Birth.” Each record in this table would have data for all three fields (though some fields can be set to be left blank in some cases, if necessary). Many records can exist in one table, all with the same fields.
To query, or retrieve, this data, a language called SQL (for Structured Query Language) is often used. There are many variants on SQL and it varies slightly database by database. A basic SQL statement though, might look something like this:
SELECT * FROM PEOPLE_TABLE WHERE FIRST_NAME = “JOHN”
As you might know, the * character means all, so this statement selects all of the records—each one represents a different person—from the table with all the people listed and shows or returns the record if the person’s first name is John. This is a very basic SQL query; they are usually much more complex, but you can get the general idea from this.
No comments:
Post a Comment