Thursday, 31 January 2013

Understanding an RDBMS


Every database is composed of one or more tables.
These tables, which structure data into rows and columns, are what lend organization to the data.
Here’s an example of what a typical table looks like:



As you can see, a table divides data into rows, with a new entry (or record) on every row. If you flip back to my original database-as-filing-cabinet analogy, you’ll see that every file in the cabinet corresponds to one row in the table.

The data in each row is further broken down into cells (or fields), each of which contains a value for a particular attribute of the data. For example, if you consider the record for the user Steve Klingon, you’ll see that the record is clearly divided into separate fields for member ID, first name, last name, phone number, and e-mail address.
The rows within a table are not arranged in any particular order; they can be sorted alphabetically, by ID, by member name, or by any other criteria you choose to specify. Therefore, it becomes necessary that you have some method of identifying a specific record in a table. In our example, each record is identified by a member ID, which is a number unique to each row or record; this unique field is referred to as the primary key for that table.
You should note at this point that MySQL is a relational database management system, or RDBMS. A relational database is typically composed of multiple tables that contain interrelated pieces of information. SQL allows you to combine the data from these tables in a variety of ways, thereby allowing you to create and analyze new relationships among your data.

What we have in our first example is a single table. While this is fine by itself, it’s when you add more tables and relate the information among them that you truly start to see the power inherent in this system. Consider the following example, which adds two more tables; the second contains a list of movies available for rent, while the third links the movies with the members via their primary keys.


If you take a close look at the third table, you’ll see that it links each member with the video(s) he or she has rented. Thus we see that Jane Doe (member #2) has rented Woman On Top (video #6), while John Doe (member #1) has decided to spend the weekend on the couch with Star Wars (video #1), ET (video #2), and Charlie’s Angels (video #3).

In other words, the third table has set up a relationship between the first and second table; this is the fundamental concept behind a RDBMS. After one or more relationships are set up, it is possible for you to extract a subset of the data (a data slice) to answer specific questions.

0 comments:

Post a Comment