Some Basics of Relational Databases

In a relational database, data is stored in tables containing rows and columns, making it easy to search and manipulate. There is some serious math behind the concept of a relational database (relational algebra, proposed by E.F. Codd at IBM in 1970), but that’s not the topic of this article.  For practical purposes (and non-mathematicians), a relational database stores related data in rows and columns. Further — and here’s where it gets interesting — most databases are designed so that the data in one table can access the data in another table. This ability to create relationships between tables is the real power of a relational database. 

Using Foreign Keys

Most tables, especially those in large, complex databases, have primary keys. Tables that are designed to access other tables must also have a foreign key. To use the commonly-cited Northwinds database, here is an excerpt from a Product table: This table also contains a foreign key column, CategoryID. Every product in the Product table links to an entry in the Categories table that defines that product’s category. Note this excerpt from the database’s Categories table: This kind of linking creates a myriad of ways to use and re-use data in a relational database.