You must create a relational dataset definition (RDD) to define the schema of a dataset before you can add records to it.
A dataset is equivalent to a table in a relational database. It can have a finite set of columns, a (nominally) infinite set of rows, and a nominated subset of columns that form (part of) the primary key.
Methods
Call the CreateRelationalDatasetDefinition API, for example:
curl -X POST 'https://<your-domain>.lusid.com/api/api/relationaldatasetdefinitions'
-H 'Content-Type: application/json-patch+json'
-H 'Authorization: Bearer <your-API-access-token>'
-d '{
"id": {
"scope": "MyDatasets",
"code": "Addresses"
},
"displayName": "Address custom dataset",
"description": "A custom dataset modelling addresses for people and organisations",
"applicableEntityTypes": ["Person","LegalEntity"],
"fieldSchema": [
{
"category": "SeriesIdentifier",
"fieldName": "AddressType",
"displayName": "Address type",
"description": "Whether a correspondence or a registered address",
"dataTypeId": {"scope": "MyCustomDataTypes", "code": "AddressType"},
"required": true,
},
{
"category": "Value",
"fieldName": "Street",
"displayName": "Street",
"description": "Building number/name and street",
"dataTypeId": {"scope": "system","code": "string"},
"required": true,
},
{
"category": "Value",
"fieldName": "City",
"displayName": "Town or city",
"dataTypeId": {"scope": "system","code": "string"},
"required": true,
},
{
"category": "Metadata"
"fieldName": "Email",
"displayName": "Contact email",
"description": "Email address for primary contact",
"dataTypeId": {"scope": "system","code": "string"}
}
]
}'Coming soon
Coming soon
Request fields
This section supplements the API documentation and on-screen help text in the LUSID web app.
A RDD:
Must have a
scopeand acodethat together uniquely identify it.Must have a
displayNameand can have adescription.Must reference at least one of the
applicableEntityTypesin the following list:Portfolio,Instrument,Transaction,Person,LegalEntity,InvestorRecord,InvestmentAccount, or a custom entity. Note each record in the dataset can be associated with one, some, or all entities of a particular type.Must have a
fieldSchemacontaining at least one mandatoryValuefield (see below).
A fieldSchema:
Can have one or more
SeriesIdentifierfields. It may have none. Note that each forms part of the primary key, in conjunction with information about associated entities. While aSeriesIdentifiercan be optional, note that if a user omits a value then part of the key will be missing for that record.Must have at least one mandatory
Valuefield. The remainder can be optional.Can have one or more
Metadatafields, mandatory or optional.
The maximum number of fields is 100, of which no more than 50 can be SeriesIdentifier fields. Each:
Must have a unique
fieldName(no spaces), and can have a verbosedisplayNameanddescription.Must have a category of either
SeriesIdentifier,ValueorMetadata.Can set
requiredtotrue. The default isfalse. At a minimum, oneValuefield must betrue.Must reference the
dataTypeIdof a built-in or custom data type with an underlyingvalueTypeofString,Int,Decimal,DateTimeorBoolean. Note arrays are not supported; if you have a list of values (for example, email addresses) then you can either delimit multiple values in a string using a suitable character, or provide a separate field for each.
Subsequent updates
If no records have yet been added to a RDD, you can update any aspect of it by calling the UpdateRelationalDatasetDefinition API.
If records have been added, do not call this API. Instead, call:
The UpdateRelationalDatasetDetails API to change the
displayNameanddescription, or to add or removeapplicableEntityTypes. Note you cannot remove an entity type if records are associated with it.The UpdateRelationalDatasetFieldSchema API to change the
fieldSchema. Note the following restrictions:Field type
Add new?
Remove existing?
Update existing?
SeriesIdentifierYes but
requiredmust befalseNo
displayNameanddescriptionrequiredbut only tofalsedataTypeIdbut only to the samevalueType
ValueYes
Yes but at least one must remain with
requiredset totruedisplayNameanddescriptionrequiredbetweentrueandfalsedataTypeIdbut only to the samevalueTypecategorytoMetadata, but at least one mandatoryValuefield must remain
MetadataYes
Yes
displayNameanddescriptionrequiredbetweentrueandfalsedataTypeIdbut only to the samevalueTypecategorytoValue
Deleting a relational dataset definition
Call the DeleteRelationalDatasetDefinition API. Note any records added to the dataset are also deleted, and can only be retrieved by rolling back the asAt timeline when calling the QueryRelationalData API.