Lesson 2 - Turning flat file into a graph

In this lesson, you'll learn how to convert a flat file into graph by extracting relationships. You will also become familiar with the Graph interface of KgBase.

3 min read - Start now

Step 1

Open the "Top Music Albums" project from the previous lesson. In data tab, locate the "Genre" column.

Click on the "..." icon that appears when you move your mouse over column header. Select the "To relationship" item.

Step 2

When creating a relationship, you have to options: A to-one relationship and a to-many relationship. After glancing at our genre column, we'll see that some albums reference multiple relationships, for example Rock, Blues.

To accommodate for these to-many genres, we'll select the to-many relationship type. We'll also have to specify a delimiter. In this case, we can leave the default , value, because our genres are separated by the comma symbol.

Step 3

The next step is to pick a target table. You have an option to match values against an existing table.

In this case, we don't have the target Genres table just yet, so we'll stick with the default "Create new table" option.

Step 4

After a short while, the table will refresh itself. You'll notice that values in Genre column are now changed from text to relationships.

Step 5

From the top menu, switch over to the graph tab. You will now see a graph with your albums and related genres. Notice that something is wrong with these graphs. Genre has the correct label, but albums are labelled by their years.

We need to change column used for graph labels in the albums table.

Step 6

Switch back to the data tab, and open Albums table. Notice that there's a "label" badge next to "Year" column. Let's instead make "Album" the label column. Click on the dots icon next to the "Album" column header, and select "Use as label".

Step 8

Now switch back to the Graph tab. Both genres and albums are now using the correct labels.