Find entities within all cards

This query retrieves entities contained within all cards. Cards might contain entities of different types, including ports, slots, and sensors. The query lists each of the cards identified and, for each card, lists the entities contained within the card.

This query does not traverse the entire containment tree within the card. Therefore, the query only retrieves components at the top level within the card.

This query uses the contains table. This table defines all the containment relationships between entities. Each row in the contains table holds a pair of entity identifiers: the containing entity and the contained entity identifier. For each card identified, the query joins to the contains table and extracts information about one of the entities contained within that card.

Example

1] SELECT     container.entityName Card_Name,
2]            m.cardNumber Card_Number,
3]            part.entityName Contained_Entity
4] FROM       physicalCard m
5] INNER JOIN entityData container ON container.entityId = m.entityId
6] INNER JOIN contains c ON c.containingEntityId = m.entityId
7] INNER JOIN entityData part ON part.entityId = c.containedEntityId
8] ORDER BY   container.entityName

The table below describes this query.

Table 1. Description of the query 

Line numbers

Description

1-3

Specify the data to show in the results, as follows:

  • The name of the card, represented by container.entityName
  • The number of the card within the main node device, represented by m.cardNumber
  • The name of the interface, represented by part.entityName

4

Use the physicalCard table as the driving table for this query.

The FROM clause extracts data for all cards.

5

For each card, extract the full set of entity data for that card. This ensures that the entity name of the card is retrieved for display in the query results, as specified in line 1). Use the alias container for the entityData table to indicate that data extracted using this alias is data for the containing card.

Do this by specifying an INNER JOIN statement with the entityData table.

6

For each card, extract records from the contains table on entities contained within that card. Limit the query results to those cards that contain other entities.

Do this by specifying an INNER JOIN statement with the contains table.

The query extracts a record from the contains table for each entity contained within a given card. Each of these records includes the entity identifier for an entity contained within the card.

7

Extract the full set of entity data for each contained entity. Use the alias part for the entityData table to indicate that data extracted using this alias is data for a contained entity.

Do this by specifying a second INNER JOIN statement with the entityData table.

8

To facilitate readability of the results, order by the entity name of the containing card.

The table below shows the results of this query.

Table 2. Results of the query

Card name

Card number

Contained entity

10.1.1.11_CARD_1

1

10.1.1.11[ 1 [ 1 ] ]

10.1.1.11_CARD_2

2

10.1.1.11[ 2 [ 1 ] ]

10.1.1.12_CARD_0

0

10.1.1.12[ 0 [ 14 ] ]

10.1.1.12_CARD_0

0

10.1.1.12[ 0 [ 10 ] ]

10.1.1.12_CARD_0

0

10.1.1.12[ 0 [ 12 ] ]

10.1.1.12_CARD_0

0

10.1.1.12[ 0 [ 11 ] ]

10.1.1.12_CARD_0

0

10.1.1.12[ 0 [ 13 ] ]

10.1.1.8_CARD_I3_R0

NULL

10.1.1.8_SLOT_I4_R0'

10.1.1.8_CARD_I3_R0

NULL

10.1.1.8_SLOT_I6_R1'

10.1.1.9_CARD_I3_R0

NULL

10.1.1.9_SLOT_I4_R0'

10.1.1.9_CARD_I3_R0

NULL

10.1.1.9_SLOT_I6_R1'

10.1.254.2_CARD_I1000_R1

NULL

10.1.254.2_SENSOR_I1002_R2

10.1.254.2_CARD_I1000_R1

NULL

10.1.254.2_SENSOR_I1001_R1

10.1.254.2_CARD_I1100_R1

NULL

10.1.254.2_PORT_I1102_R1

10.1.254.2_CARD_I1100_R1

NULL

10.1.254.2_PORT_I1101_R0