Storing Hierarchical Data in a Database

Instructor: Kaitlin Oglesby

Kaitlin has a BA in political science and extensive experience working in the business world as Director of Marketing and Business Development at a financial advice firm.

Hierarchical databases are some of the most intuitive for us to understand. In this lesson, we see how data fits into a hierarchical database typical to many organizations.

What Is a Hierarchical Database?

One of the earliest types of computerized databases, and still one of the most useful, is the hierarchical database. Hierarchical databases are made up of layers of information in which each table links to one above it, and each table could have a number of other tables or records below it. In short, a hierarchical database looks a bit like a pyramid.

In this lesson, we are not only going to learn how to further visualize a hierarchical database, but we will also explore how to put data into one. Further, we'll see how these databases are not necessarily perfect.

Visualizing a Hierarchical Database

To really put together the best possible mental image of a hierarchical pyramid, let's start at the top. Say that you were building a database for all of your movies. Therefore, your first table may very well be just genres of movies. From there, you'd probably like to separate them into different genres. To keep things simple, let's say that you just want to distinguish between children's, romance, and action movies. Each of those tables would be a child table to the table 'movies', which is in turn the parent table.

Now here's where things get interesting. Let's look at one of those categories, romance, for an example. You could then put child tables in it, say for historical romance, modern romance, or classic romance. After all, you don't want You've Got Mail getting confused with Casablanca, now do you! Each of those tables would in turn be a child table to the romance table, which is now a parent table.

As you can see, a table can be a parent table as well as a child table. This hierarchy-based structure is what gives this database type its name.

Disadvantage

Still, while a hierarchical database may sound very logical, it does have one major flaw. Let's say that you had a record that could feasibly go on two tables - for example, the action movie Jurassic World has a pretty good romantic plot line too, so you might want to include it in both your action and romance categories.

In a relational database, you could simply link the two tables to the record at the same time. However, with a hierarchical database, you have to choose one table that is the 'parent' directory, while the other table is left without the record. As such, in highly linked databases, a hierarchical database would not demonstrate all the relationships between information.

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account
Support