Ask yourself this, how many times have you actually heard the word database in the context of this magical data storage device? Well if you haven’t been asleep for a decade or so before than reading this, than I’ll just assume that the answer is quite a lot. Its nobody’s fault if they do this sort of thing, they just don’t know any better and don’t want to admit it. That’s why in this article, we’re going to go over what a database actually is to end this!
The Four Key Terms Of Database
To start off, there are four main elements that you should know in regards to tables. These being rows, columns, fields and foreign keys.
A row represents entries of related data belonging to one set. To simplify this, think of a database that is holding information on people who register for a site. Every person registered will have all the information they entered in a row in a database that is dedicated to their username.
So if Amy is to register for a site with her name, age, username, password, and address, then all of that should be in her identified row. Easy enough to follow and understand right?
Moving on, we’ll now talk about what exactly a column is. In the simplest of terms, a column is a collection of data of a similar type where a each row only has one entry. As an example, let’s go back to our site registration from earlier. As mentioned the site takes particular information from users, one being the user’s name.
This name field will be represented in the database as a column where every row will place their name values. Not too much to Keep up with right?
Since we’ve gone over how they’re organized, let’s actually discuss fields now. Fields and columns have a direct relationship because the column a field is in defines what type of data will be stored in that field. Again, this one was quick and easy as well.
Moving on into our last topic of the big four, this allows us to now gain brief introduction into how a relational database operates. Foreign keys are unique identification field(s) used to identify a specific row in table so that it can create a link between tables.
For an example, let’s say that all of Amy’s information is stored in a database table called user accounts. Now there is another database table that holds payment information, things like credit card and/or bank account information, and to properly access this information for the scheduled periodic payment the payment information table needs to get some information from the user account table. To do this we add a column to the table called userid which will hold a row reference for users in the user account table.
Now that we’ve gone over the basics of how data is organized inside a database, let’s take a look at the actual data that’s in there. Now this is a very subjective topic because programming languages, or types of databases, don’t support the same data types. However, there are three that you could consider common enough to in all of them. As you’ll now see below.
- Boolean: true or false value
- Integer: numeric value
- String: character cluster, or text
There are also types for dates, timestamps, decimal approximations, and some more. We don’t want to overload your head to soon, so we’ll save those for a later class session.
Database Table Relationships
To end our class session, we’re going to close out with the different relationships tables can have with one another. Its pretty basic stuff so we won’t spend too much time with it. In a nutshell there are three different types of relationships: one to one, one to many, and many to many. Its so simple no need for a breakdown right? Well just in case, we’ll do one anyone.
First things first, when we’re talking about these relations the reference being made is between the interaction of rows in other tables with each other. Its a pretty simple concept, so again will just outline all you’ll need to know in bullet points.
- One to one: a row in one table can only have one reference to a row in another table
- One to many: a row in one table can be a reference to many rows in another table
- Many to many: there can be multiple rows referencing multiple rows in another table
Well, that’s the bare bones idea. Now next time, we’ll take a much bigger step into the details.