Objects of the Logical Data Model
We are continuing in our series of articles about Logical Data Model in GoodData, this time we will describe what objects you can find in the model.
If you have not done it yet, you should also read the previous article in this series: Logical Data Model - Introduction where we have explained what Logical Data Model is and why it is important to understand it.
Logical Data Model consists of a handful kinds of objects:
Dataset is an object in a Logical Data Model. It is a collection of related facts, attributes and references. You can imagine a dataset as a table. (It can physically consist of multiple tables, but on a logical layer, a table is still a very good approximation). Datasets hold the data loaded into them.
In the tool for creating Logical Data Models in GoodData, a dataset is displayed as a box. For example, here is a dataset “Product”:
If you think of a dataset as a table, think of an attribute as a column - more precisely, a column with a string value in it. It typically has some text value in it and gives context to the facts. Attribute values are used for slicing and filtering.
Attributes are displayed as lines with the “ABC” icon (or sometimes “key” icon) within datasets. “Product Type” is an attribute of the dataset “Product”.
Under a single attribute, there can be one or more variants or as they are called in GoodData “labels.” For example, in the case of the “Customer” attribute, there can be “Customer Name“ (the actual human readable name) but also Customer ID (numerical ID used for references) and even “Customer GPS,” which contains the coordinates of that customer to display it on a map. These alternate “labels,” while still representing a single attribute, function as separate columns during the data load. They are not visible in the standard model view, but they can be displayed in the “view details” dialogue for each dataset.
If you think of a dataset as a table, think of a fact as a column - more precisely, a column with a numerical value in it. They are measurements, amounts, sizes etc. Facts are used in Metrics - typically, facts are aggregated. Facts within one dataset should ideally all have the same granularity which is defined by the primary key of that dataset.
Facts are displayed as lines with the “123” icon within the datasets.
A reference is a way in which datasets can be joined together. End users building the Insights do not need to write explicit database joins like in SQL - all the joins are pre-defined within the Logical Data Model in advance. In GoodData you can only join datasets based on a single-column key.
References are represented as arrows between the datasets. A one-way arrow represents a one-to-many relationship (note that in GoodData the arrow goes from the Primary Key to the Foreign Key - the opposite of some other tools). Two-way arrows represent a many-to-many relationship.
In our sample model, there are several references. For example, the one between “Order” and “Customer” datasets. The arrow goes from Customer to Order, which means that each order needs to have exactly one customer. You can also see that there is a Customer key in the Order dataset under the line, which means that a foreign key is referencing the Customer attribute.
Note that the arrows in the diagram point between datasets generally, and they do not necessarily point to a specific attribute or foreign key—though it may appear that way.
The reference between “Product” and “Product Tag” is an example of a many-to-many reference where each product can have multiple tags, and each tag can be assigned to multiple products.
Dates have a special role in GoodData and are represented by Date Dimensions. You connect a Date Dimension to your dataset by a reference (like you would connect any other dataset).
which are referenced from datasets. Each date dimension contains a standard calendar ranging between 1900 to 2050 and can be loaded with customized content (i.e. fiscal calendar) if needed. Note that the built-in date dimension in GoodData does not contain the time portion in it.
Sales Date and Shipment Date are examples of date dimensions.
Next article in this series is: Logical Data Model - Basic Rules of Data Modelling
Let us know how you like this series and feel free to post questions if something is not clear to you. For more information and practice about data modelling, please also attend our free courses at GoodData university.