The CreatorCon Call for Content is officially open! Get started here.

Data base view creation between api and api_component table

keshav77
Tera Contributor

Hi All,

I am trying to create a database view by joining cmdb_ci_api & cmdb_ci_api_component  table

Purpose of this join is to find out which to find parent child relation ship between them.

I created a database view as but I am little bit confuse what where clause I need to use in this case.

 

Currently I  am using in cmdb_ci_api_component -- com.sys_id=api.sys_id

and 

 cmdb_rel_ci --  rel.parent=api.sys_id

 

But this not working currently.. kindly assist me in this 

 

 

1 ACCEPTED SOLUTION

hi @keshav77

Common Reasons for No Data:
 

No Actual Relationships: You might have cmdb_ci_api and cmdb_ci_api_component records, but no actual relationship records (cmdb_rel_ci) have been created between them.
Incorrect Relationship Type: The most frequent culprit. The type.name you're using ('Used by') does not match the actual relationship type defined in your CMDB for these CIs.
No Data for One of the Tables: If any of the three tables (cmdb_ci_api, cmdb_ci_api_component, cmdb_rel_ci) are empty or lack records that meet the join criteria, the view will be empty.
 
 
Test the cmdb_rel_ci Query in Isolation:
This helps isolate if the issue is with the relationships themselves.
If this query returns no records, then your database view will also return no records, because the underlying relationships don't exist or don't match your WHERE clause.
A small request from my end, If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer🌠‌ OR  mark it  Helpful ‌‌ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community

 

MackI | ServiceNow Technical Consultant | DXC Technology Australia | ServiceNow Practice | LinkedIn Top IT Operation Voice 2023 | Sydney,Australia

View solution in original post

10 REPLIES 10

keshav77
Tera Contributor

@Ankur Bawiskar  any suggestion on this

Mohammad Danis1
Giga Guru

@keshav77 , Typically, these tables could have a common field that allows us to join them together.

Regards,
Mohammad Danish

Ankur Bawiskar
Tera Patron
Tera Patron

@keshav77 

the tables "cmdb_ci_api" & "cmdb_ci_api_component" are just another class and are an extension of cmdb_ci

It's similar to other CI tables which extend cmdb_ci table

What's your exact requirement to join those tables?

You are trying to join parent and child but why?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  we are creating a parent child relation between them where api is parent table and api_component is child table. I am trying to create a database view on the basis of there relation ship and try to show the record in that view table.. but some how data is not getting visible if we click on try. I am sharing view screenshot with you 

keshav77_1-1751880412198.png