Contentful logo

Contentful Community

Splitting a record and creating relations while importing

#1

I’m going to import data into contentful. I have a data structure that contains fields that I want to split while importing.
I see that Contentful has a field type called Reference and that I need to create these automatically during import. I’m coming from the world of relational databases and I’m not sure how to model the data in a system like Conentful.

I have created a small dataset that illustrates the challenge.

Let’s say the data structure like this:
{
company: “Microsoft”,
zipCode: 98052,
city: “Redmond”,
mainContactPerson: “Satya Nadella”
}

I want to split this record into several records in Contentful.
company, zipCodes, person and companyContact

To something like this:

company = [
{
companyName: “Microsoft”,
zipCode: 98052
}
]

zipCodes = [
{
zipCode: 98052
city: “Redmond”
},
{
zipCode: 98051
city: “next city”
},
]

person = [
{
name: “Satya Nadella”
},
{
name: “next person”
}
]

companyContact = [
{
companyKey : ?
personKey: ?
mainContactPerson: “yes”
}
]

0 Likes