Relationships data object - id is not primary key - ability to rename id key

Sorry if this is not the right place for this kind of problem or if someone else already faced with the same problem.
Fell free to redirect me or whatever.

So I just faced a problem when I do not use id as a primary key. I would need something like this (see relationships dispatchers data part):

{
  "data": {
    "type": "driver",
    "attributes": {
      "first_name": "First name",
      "last_name": "last name",
    },
    "relationships": {
      "dispatchers": {
        "data": [
          {
            "type": "dispatcher",
            "tspa_id": "8"
          },
          {
            "type": "dispatcher",
            "tspa_id": "7"
          }
        ]
      }
    }
  },
  "included": [
    {
      "id": "",
      "type": "dispatcher",
      "attributes": {
        "first_name": "Maybelle",
        "last_name": "Merlin",
        "tspa_id": "7" 
      }
    }
  ]
}

So I am not sure if my suggestion is good, but I think that json api specification should allow us to:

  • rename primary key

  • use another key as primary key

Any other opinions or solutions?

Thanks!

You are confusing your JSON:API schema and you database schema. The JSON:API specification never mentions the terms “primary key”.

Can you tell us a little more about what you are trying to achieve? Why can’t the driver have an ID? Why can’t a dispatcher use the name ID?