Back Arrow
From the blog

Inspecting raw database data in Xperience by Kentico

This article is a cheat sheet to inspect what's going on with the imported data by Xperience by Kentico Migration Toolkit, resolve some CI/CD issues and on many other occasions!

Dmitry Bastron

Solution Architect / Kentico MVP

tl;dr

Below are just links to the SQL code snippets, make sure to pin and make use of them!

Why would I write SQL queries again?

It's been over a year since Kentico delivered a massive content structure modernization Refresh. The underlying database schema underwent significant changes to support the rapid growth of the Xperience by Kentico product.

In their daily tasks, developers don't usually need to remember the structure of the database tables and how they relate to each other. Kentico provides robust and flexible APIs that make it easy to query the data they need: Content Hub items, Web Pages, Objects, and Database Tables. But what if you execute the query, and the data returned is not what you expect? And why may this happen?

Occasionally, I find myself writing the same SQL queries to check what is stored in the database vs what I see (or don't see?) on the screen. Kentico provides a great documentation article explaining what information is stored in which database table.

This article is just a cheat sheet for those of you, who are about to:

  • inspect what's going on with the imported data by Xperience by Kentico Migration Toolkit
  • resolve CI/CD issues when a member of your team forgets to commit some of the XML files
  • investigate a loss of data after the change of content model
  • checking the data after the update, and on many other occasions

Content Hub item properties

Let's start with easy things, this is basic information about the content hub item - a coffee product "El Salvador Finca San Jose" from the Dancing Goat website:

Here is the summary of the tables we need to join:

  • CMS_ContentItem - basic item global info, one record across all languages
  • CMS_ContentItemCommonData - basic item language-specific info, one record per language, also contains all reusable field schema fields from all content types
  • CMS_ContentItemLanguageMetadata - published and scheduled status, created/modified by who and when
  • CMS_ContentLanguage - all languages in the system
  • CMS_Class - all content and object types registered in the system (both Kentico and your custom ones)

Notice that I'm using LEFT joins here, and it's for a reason. This will help you identify missing or orphaned records if there were any. Missing or orphaned records may appear in your database due to incomplete data migration or CI/CD restore with some files missing.

Custom content type fields

Moving on, let's add our custom content type fields to the query:

Each custom content type has a dedicated SQL table to store custom field data, usually named <namespace>_<customTypeName>. We need to join it with the following condition: ContentItemDataCommonDataID foreign key, and filter out our specific content type 'DancingGoat.Coffee':

Reusable field schemas

You will immediately notice that our last query returns fewer fields than you can see in the user interface. This is because the Coffee content type has some of its fields inherited from Product fields reusable field schema:

These fields need to be queried from CMS_ContentItemCommonData table we joined earlier:

Content hub assets (images)

The next thing you will notice is how Xperience by Kentico stores references to images (or any other assets) stored in Content Hub. Documentation guides recommend storing images in the Content Hub, and Dancing Goat follows this guide.

The previous query will return the following result for the ProductFieldsImage field:

[{"Identifier":"279bb55f-81e3-4d93-9cff-8372dc34cdc5"}]

That is a unique identifier of our image - yet another item from the Content Hub of DancingGoat.Image type, and with the query below we can get some useful metadata information, and can even locate this asset on disk when we need to inspect the binary:

Taxonomy

Other fields from the previous queries where you will find unique identifiers are CoffeeProcessing and CoffeeTastes, these are Taxonomy fields, and they store a list of TagGUID records from CMS_Tag table:

This way we can join this data if needed:

Web Pages

And finally, web pages from the Web channel. In Xperience by Kentico every web page is a little bit of content item 😊

We just need to join a couple more tables:

  • CMS_WebPageItem - basic CMS tree global info, one record across all languages
  • CMS_WebPageUrlPath - URLs table, one record for each language

Other helpful tools

The queries above are beneficial while debugging data issues. But what if you need to check what SQL queries Xperience generates when you call query APIs? In this case, integration with MiniProfiler would be very helpful! Check out this nuget package by Sean G. Wright. I think this is one of the must-have packages you should install for every project!

Conclusion

Don't be afraid of making your hands dirty again by writing some SQL queries to identify data issues within your Xperience by Kentico solution. Hopefully, these little code snippets together with Kentico's detailed documentation will give you some good boosting when you start investigating things!

It's easy to start working with us. Just fill the brief or call us.

Find out more
White Arrow
From the blog
Related articles

Learnings from using Sitecore ADM

Anna Bastron

Let's try to understand how the ADM module works, its limitations and tactics for optimising its performance.

Sitecore

Your last migration to Xperience by Kentico

Dmitry Bastron

The more mature Xperience by Kentico product becomes, the more often I hear "How can we migrate there?”

Kentico

5 Key Software Architecture Principles for Starting Your Next Project

Andrey Stepanov

In this article, we will touch on where to start designing the architecture and how to make sure that you don’t have to redo it during the process.

Architecture
Software development

Assessing Algorithm Complexity in C#: Memory and Time Examples

Anton Vorotyncev

Today, we will talk about assessing algorithm complexity and clearly demonstrate how this complexity affects the performance of the code.

.NET

Top 8 B2B Client Service Trends to Watch in 2024

Tatiana Golovacheva

The development market today feels like a race - each lap is quicker, and one wrong move can cost you. In this race, excellent client service can either add extra points or lead to a loss dot to high competition.

Customer Service
Client Service

8 Non-Obvious Vulnerabilities in E-Commerce Projects Built with NextJS

Dmitry Bastron

Ensuring security during development is crucial, especially as online and e-commerce services become more complex. To mitigate risks, we train developers in web security basics and regularly perform third-party penetration testing before launch.

Next.js
Development

How personalisation works in Sitecore XM Cloud

Anna Bastron

In my previous article, I shared a comprehensive troubleshooting guide for Sitecore XM Cloud tracking and personalisation. This article visualises what happens behind the scenes when you enable personalisation and tracking in your Sitecore XM Cloud applications.

Sitecore

Server and client components in Next.js: when, how and why?

Sergei Pestov

All the text and examples in this article refer to Next.js 13.4 and newer versions, in which React Server Components have gained stable status and became the recommended approach for developing applications using Next.js.

Next.js

How to properly measure code speed in .NET

Anton Vorotyncev

Imagine you have a solution to a problem or a task, and now you need to evaluate the optimality of this solution from a performance perspective.

.NET

Formalizing API Workflow in .NET Microservices

Artyom Chernenko

Let's talk about how to organize the interaction of microservices in a large, long-lived product, both synchronously and asynchronously.

.NET

Hidden Aspects of TypeScript and How to Resolve Them

Dmitry Berdnikov

We suggest using a special editor to immediately check each example while reading the article. This editor is convenient because you can switch the TypeScript version in it.

TypeScript

Troubleshooting tracking and personalisation in Sitecore XM Cloud

Anna Gevel

One of the first things I tested in Sitecore XM Cloud was embedded tracking and personalisation capabilities. It has been really interesting to see what is available out-of-the-box, how much flexibility XM Cloud offers to marketing teams and what is required from developers to set it up.

Sitecore

Mastering advanced tracking with Kentico Xperience

Dmitry Bastron

We will take you on a journey through a real-life scenario of implementing advanced tracking and analytics using Kentico Xperience 13 DXP.

Kentico
Devtools

Why is Kentico of such significance to us?

Anastasia Medvedeva

Kentico stands as one of our principal development tools, we believe it would be fitting to address why we opt to work with Kentico and why we allocate substantial time to cultivating our experts in this DXP.

Kentico

Where to start learning Sitecore - An interview with Sitecore MVP Anna Gevel

Anna Gevel

As a software development company, we at Byteminds truly believe that learning and sharing knowledge is one of the best ways of growing technical expertise.

Sitecore

Sitecore replatforming and upgrades

Anastasia Medvedeva

Our expertise spans full-scale builds and support to upgrades and replatforming.

Sitecore

How we improved page load speed for Next.js ecommerce website by 50%

Sergei Pestov

How to stop declining of the performance indicators of your ecommerce website and perform optimising page load performance.

Next.js

Sitecore integration with Azure Active Directory B2C

Dmitry Bastron

We would like to share our experience of integrating Sitecore 9.3 with the Azure AD B2C (Azure Active Directory Business to Consumer) user management system.

Sitecore
Azure

Activity logging with Xperience by Kentico

Dmitry Bastron

We'll dive into practical implementation in your Xperience by Kentico project. We'll guide you through setting up a custom activity type and show you how to log visitor activities effectively.

Kentico

Interesting features of devtools for QA

Egor Yaroslavcev

Chrome DevTools serves as a developer console, offering an array of in-browser tools for constructing and debugging websites and applications.

Devtools
QA

Kentico replatforming and upgrades

Anastasia Medvedeva

Since 2015, we've been harnessing Kentico's capabilities well beyond its core CMS functions.

Kentico

Umbraco replatforming and upgrades

Anastasia Medvedeva

Our team boasts several developers experienced in working with Umbraco, specialising in development, upgrading, and replatforming from other CMS to Umbraco.

Umbraco

Sitecore Personalize: tips & tricks for decision models and programmable nodes

Anna Gevel

We've collected various findings around decision models and programmable nodes working with Sitecore Personalize.

Sitecore

Fixed Price, Time & Materials, and Retainer: How to Choose the Right Agreement for Your Project with Us

Andrey Stepanov

We will explain how these agreements differ from one another and what projects they are suitable for.

Customer success

Enterprise projects: what does a developer need to know?

Fedor Kiselev

Let's talk about what enterprise development is, what nuance enterprise projects may have, and which skills you need to acquire to successfully work within the .NET stack.

Development

Headless CMS. Identifying Ideal Use Cases and Speeding Up Time-to-Market

Andrey Stepanov

All you need to know about Headless CMS. We also share the knowledge about benefits of Headless CMS, its pros and cons.

Headless CMS

Dynamic URL routing with Kontent.ai

We'll consider the top-to-bottom approach for modeling content relationships, as it is more user-friendly for content editors working in the Kontent.ai admin interface.

Kontent Ai
This website uses cookies. View Privacy Policy.