# Locating realm role's associated attributes in postgres

**URL:** <https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279>\
**Category:** Getting advice\
**Tags:** database\
**Created:** [October 10, 2024, 9:00pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279 "2024-10-10T21:00:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitinramvelraj](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/nitinramvelraj/32/11415_2.png) [@nitinramvelraj](https://forum.keycloak.org/u/nitinramvelraj)\
**Post date:** [October 10, 2024, 9:00pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/1 "2024-10-10T21:00:34Z")

</div>

I can see that the realm roles are under a table called keycloak\_role. In the UI I have the associated roles through which I can assign a client role to the realm role. I want to see this in the postgres database. Which other tables should I be looking at. I can find my client role in keycloak\_role table as well. Just need to find how then realm role is linked with the client role. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [October 10, 2024, 9:24pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/2 "2024-10-10T21:24:13Z")

</div>

See table `composite_role`.

---

<div class="post-metadata">

**Author:** ![nitinramvelraj](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/nitinramvelraj/32/11415_2.png) [@nitinramvelraj](https://forum.keycloak.org/u/nitinramvelraj)\
**Post date:** [October 10, 2024, 9:37pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/3 "2024-10-10T21:37:02Z")

</div>

sweet, got it thanks.

---

<div class="post-metadata">

**Author:** ![nitinramvelraj](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/nitinramvelraj/32/11415_2.png) [@nitinramvelraj](https://forum.keycloak.org/u/nitinramvelraj)\
**Post date:** [October 11, 2024, 6:04pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/4 "2024-10-11T18:04:04Z")

</div>

Follow up @dasniko . I want to allocate a client role to a realm role from the database. In order to do this, I’ve found the id of the client role I need to allocate and the id of the role I want to allocate this to and inserted a new row in the composite\_role table with the composite column value as the role to which I want to assign the client role to and the child\_role value as the client role. But when I go to my keycloak UI I don’t see this reflected as a change (the realm role doesn’t have the client role attache to it). Are there other db actions I need to perform for this to take place? When I remove this row and add the client role from the UI I see the same db row being inserted.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [October 11, 2024, 7:25pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/5 "2024-10-11T19:25:28Z")

</div>

Never work on the DB directly, that’s the last thing you want to do. Always use the API.  
Thank me later.

---

<div class="post-metadata">

**Author:** ![nitinramvelraj](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/nitinramvelraj/32/11415_2.png) [@nitinramvelraj](https://forum.keycloak.org/u/nitinramvelraj)\
**Post date:** [October 11, 2024, 10:02pm UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/6 "2024-10-11T22:02:46Z")

</div>

Haha, ok thanks! I’ll do that. But just for my understanding I wanted to try this out and it seems like once I added the row and restarted keycloak the composite\_role I added gets picked up. My suspicion is that there is a cache that it reads from.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [October 12, 2024, 6:14am UTC](https://forum.keycloak.org/t/locating-realm-roles-associated-attributes-in-postgres/28279/7 "2024-10-12T06:14:58Z")

</div>

Yes, Keycloak makes heavy(!) use of a cache. This might lead to inconsistencies when operating directly on the DB and have a running server. Additionally, the data model is a bit complex and if you don’t understand it entirely, you might miss some data/tables/columns. This might not be the case for roles, but other entities.
