When creating an object, I want to make sure any further data added to this object meets the primary key uniqueness criteria. How do I set such configuration so that any added object meets the pk condition.
Hey Rebecca,
Let’s break this down by different ways to add new objects
-
Adding a new object using an ontology actions
- In this case, a
[Actions] ObjectsAlreadyExist
error will be thrown if you try to create a new object with a duplicate primary key. So we take care of preventing duplicates for you here.
- In this case, a
-
Adding a new object from a dataset build
- If you are using OSv2 (Object Storage v2), if new rows are added to your dataset, and it results in duplicate values for the column being used as the primary key, then this will cause an indexing failure so the duplicate objects will not show up (source). However, this also means that other valid new dataset updates also does not show up - which you probably do not want. If you are using OSv1, no indexing failure will occur. Instead, a random row will be picked and this might change between syncs. Again, you probably don’t want this.
- To prevent, duplicate primary keys during builds regardless of the object storage version being used, you can set up a data expectation that will fail if there are duplicate primary keys in your dataset-build. You can do this in pipeline builder or in code repositories, depending on where you build your object-backing dataset.
-
Forcing Uniqueness
- If what you want to do is force that every new row coming from your data source and every new object created by an action has a unique primary key, one way to do this is to use a UUID (Universal Unique Identifier). You can use an automatically generated UUID as the primary key value for every new object created or for every new row of data coming in from your data source. This is not guaranteed to be unique but the probability of a duplicate in sufficiently low for most purposes. However, be cautious when using these in dataset builds because the UUIDs might change between builds
1 Like