Hello Team, Can we add two columns as primary key column in tiger graph

Hello Team, Can we add two columns as primary key column in tiger graph.

Hi @Parshva007 ,

We have a composite key feature in TigerGraph, but it’s not currently supported in Graph Studio. E.g. if you have a vertex with composite keys, you can’t use it in Graph Studio.

See here for more information: Defining a Graph Schema :: GSQL Language Reference


As for the workaround if you want to use two columns as a “primary key”… In the graph schema, I would suggest having 1 PRIMARY_ID column that’s the concatenation of the two columns you originally want to use as primary key. You should be able to do the concatenation of both data in the loading job.

For instance, suppose you have a database with both book_id (e.g. “12345”) and chapter_id (e.g. “001”), and you want to make both book_id and chapter_id a composite key in the database. You can have a new PRIMARY_ID book_chapter_id, where its content would be book_id + “-” + chapter_id instead (e.g. “12345-001”).

I hope this helps! Please let us know if you have any further questions.

Best,
Supawish Limprasert (Jim)

2 Likes