Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

what is the primary key of a table?

jerryt
Tera Contributor

Hi there,

I'm using Helsinki and I'm wondering what is the primary key in a table.

It looks that most of the tables have a column 'sys_id', which seems like the primary key in that table. When I navigate to 'Tables and Columns', I see a big blue circle icon with an 'i' inside beside sys_id: pk.PNG

But some tables don't have sys_id. For example, pa_favorites and v_db_index seem not to have primary keys.

There's another interesting table. ts_word_roots has 3 columns and they are like this:

ts_word_roots.PNG

So my questions are:

1. How can I check what is the primary key in a table? (usually sys_id I guess, but I'm not sure)

2. Are there any tables without primary keys? (like pa_favorites and v_db_index?)

3. For table ts_word_roots, does it have a composite primary key?

Thanks a lot!

1 ACCEPTED SOLUTION

Hi Jerry,



Yes, where there is a sys_id, that's the primary key. I checked some of the others you mentioned and here's what I found.


  • pa_favorites - PRI=user
  • v_db_index - PRI=sys_id
  • ts_word_roots - PRI=index,raw_word,stemmed_word


Let me know if there are any other specifics you need.


View solution in original post

11 REPLIES 11

find_real_file.png


That's weird, I really don't see sys_id in that table. Here's the response from mysandbox.service-now.com/v_db_index.do?SCHEMA:


<v_db_index>


      <element name="column_names" internal_type="string" max_length="1000" choice_list="false"/>


      <element name="table_name" internal_type="table_name" max_length="80" choice_list="false"/>


      <element name="index_name" internal_type="string" max_length="80" choice_list="false"/>


</v_db_index>


As you can see, there're only 3 columns show up.


v_db_index .PNG


In the picture above, I do see the primary key is sys_id, but it's just invisible. Is it an inaccessible column?


Because it starts with v_, it denotes a database view. That makes it special. I don't know the technical underpinnings of how database views work. Suffice it to say, MySQL's desc command isn't lying to me.



Anything else?


I see, thanks man.


Oh how about the table ts_word_roots? It has 3 indexed columns, so does it have a primary key consisting of all the 3 columns? Thanks