Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Modeling Data

dkapoor edited this page Apr 22, 2015 · 20 revisions

Data modeling is the process of mapping your data to an ontology so that Karma can integrate it with data from other sources and publish it in a new format. To model your data you need to first import your data and the ontologies you want to use to model your data (see Importing Data).

If you have not defined a model for this source yet, Karma will show an empty model as indicated by the small red circles above each column heading:

The modeling process consists of the following activities:

Specifying Semantic Types

A semantic type defines the relationship between a column of data and a property and a class in your ontology. For example, in the artworks-list.xml data shown above, we want specify that the artist column contains the names of people. We can do this by mapping the artist column to the foaf:name of a foaf:Person (foaf is a popular ontology for modeling data about people http://xmlns.com/foaf/spec/). Karma is ontology agnostic, so you can use whatever ontology you want to model your data.

To specify a semantic type click on the column headings. A dropdown menu appears. Select Set Semantic Type. Clicking on Set Semantic Type for artist shows a panel such as the following.

Semantic types can be specified in several different ways and can combine multiple pieces of information. We explain each of these in turn:

Basic Semantic Types

The most common way of constructing a semantic type is to define it based on a property and a class in your ontology. When you use Karma on multiple data sources related to the same domain (e.g., several data sources with data about museums), Karma will learn the semantic types you assign to data, and offer them as suggestions.

In this example, we had been using Karma to model several museum sources so Karma shows the top-ranked suggestions for the semantic type for the artist column. Click on the check box to select foaf:name of foaf.Person1 and click submit to assign it. Karma updates the model to show your semantic type assignment:

Editing Suggestions

Sometimes, the suggested semantic types are not exactly what you want. In these cases, you can can click on the small Edit buttons on the right to edit any of the semantic types. For example, you can click on the first Edit button to edit the first foaf:name suggestion:

You can type-in the name of a data property or a class name in the appropriate box. Karma provides the list of all classes and properties in the listboxes and you can select them to select the required class and property. Karma also offers type-in completion to narrow the results in the listboxes. The green results are the narrowed down results. If no results are found, Karma rejects the input and shows the entire list, which will be in the default black color.

Multiple Semantic Types For a Column

Often you may want to assign multiple semantic types to a column. For example, you may want to model the artist column as the foaf:name of a foaf:Person and you also want to model it as the rdfs:label as the name is an appropriate label for people (it is good practice to define an rdfs:label for all classes in your models).

To do this, you can create a duplicate of the column artist_copy and set the semantic type of artist-copy as rdfs:label of foaf-Person. Click on artist and select PyTranform. Enter the name of the column as artist_copy and then click Save. This will create a column artist_copy with the same value as artist. Now, click on artist_copy, click Set Semantic Type and then select rdfs:label of foaf-Person1. This creates the following model

Multiple Columns With the Same Semantic Type

Sometimes you have a situation where a source contains two columns with the same type of data, but the data in one column refers to different individuals than the data in the other column. For example, consider the following dataset containing data about artworks. The Artist column contains the name of the creator of the artwork so we modeled it as the name of a foaf:Person (Karma does not show the prefixes). The Sitter column also contains the names of people, but these are the names of the people depicted in the artwork.

It is important for the model to specify that the artist and the sitter are different people. This is what the indices after the class names are for (e.g., the 1 in Person1). If the artist is Person1, we want the sitter to be a different person, say Person2.

Here is the semantic types dialogue that Karma shows when you click on Set Semantic Type for Sitter:

foaf:name of foaf:Person1 is a suggestion that the Sitter column contains a foaf:name for Person1, the same person that we used to represent the artist. This is not what we want.

The next entry, foaf:name of foaf:Person2 (add) suggests that you can add a new person to your model, Person2, to represent the sitter. This is precisely what we want. The following screen shows the resulting model when you select Person2 for the sitter:

The model contains two person bubbles: Person1 for the artist and Person2 for the sitter. Both columns contains the names, so we used the foaf:name property in both semantic types. The other bubble, CulturalHeritageObject1 represents the artwork and the creator and sitter links represent the relationships between the artwork and the people (see section on Specifying relationships among classes for an explanation about relationships among classes).

URIs for Classes

Every bubble in your model represents a class of entities in the world. For example, Person1 in the following model represents the class of artists. Different records in your dataset typically represent different specific entities. For example, in the first row, Frishmuth, Harriet Whitney is the name of one artist, and Archipenko, Alexander is the name of a different artist:

When we model datasets, we typically want to assign unique identifiers to each entity mentioned in a dataset so that we can refer to them later when we publish the data. This is especially important when we have multiple datasets that refer to the same individual and we want to make sure that the data is cross-refenced appropriately so that we can merge the data about the same individuals when they are mentioned in different datasets. For example, we may have an "artworks" dataset that tells us that Alexander Archipenko created the bronze statue titled Concave of Standing Woman, and we may have an "artists" dataset that tell us that he was born in Kiev. We want our models to define a unique identifier to Alexander Archipenko so that all the data about him is tied to the same identifier.

If you want absolute control over the URIs for entities, you can store them in a column in your dataset and tell Karma to use those URIs for the entities in your class. The following screenshot shows our "artworks" dataset transformed using PyTransform to add a column that explicitly provides the URI that we should use for each artist:

You can tell Karma to use the URIs in column artist_uri as the URIs for Person1 by editing the uri of Class option in the semantic types dialogue box. Enter the class as foaf:Person1:

When you click Save, Karma will updates the model. The label uri shows that a column is being used to specify the URI for a class.

When you publish the data in RDF, Karma will use the URIs you specify to define the URIs for your entities. For example, the URI for Alexander Archipenko will be http://ima.org/people/lexander_Archipenko.

Note: if your model has a class for which you don't specify a URI, then Karma will generate a blank node for it. All the data within a single dataset will be self consistent, but there will be now way to cross-reference the entities in that class with entities in the same class in other datasets. It makes sense to use blank nodes for classes that you use to group information together, but which don't correspond to an entity in the world.

Literal Types

You can explicitly define the types of literals using the Literal Type option in the panel for specifying semantic types. Karma offers the standard XSD types in a menu and also allows you to enter your own URIs if that is appropriate for your application.

Specifying Relationships Among Classes

Automatically Defining Ontologies To Model Sources

Managing the Models for a Source

Clone this wiki locally