MongoDB Connector > Introduction to MongoDB Connector > Virtual tables
  

Virtual tables

The Simba MongoDB JDBC driver creates virtual tables if the column family contains collections such as arrays and objects.
Virtual tables depict the renormalized view of a MongoDB collection. You can use virtual tables as sources and targets in mappings.
The Simba MongoDB JDBC driver creates a virtual table for each collection in the column family. The virtual table for a collection uses the following naming convention by default: <original column family name>_<original collection name>
Each virtual table has a foreign key column that references back to the primary key column in the original collection. The key column uses the following naming convention by default: <original collection name>.<primary key column name>
The virtual table has an index column that shows the position of the data within the original array. The index column uses the following naming convention by default: <original column name>_index
Other columns in the virtual table represent the elements in the array and are named after the array element. If the array is of scalar type, the data column uses the following naming convention by default: <original column name>_value
When you use a virtual table in a mapping, you can perform read, insert, and update operations on a virtual table.
Note: You cannot perform upsert or delete operation on a virtual table.

Virtual tables example

The collection CustomerTable contains arrays. You want to create virtual tables from the arrays and import the virtual tables as data objects in Informatica Cloud.
The following table shows the schema of CustomerTable collection:
id
Customer Name
Invoices
Service Level
Contacts
Ratings
1111
John
[{invoice_id=123,item=toaster, price=456,discount=0.2},
{invoice_id=124,item=oven, price=12345, discount=0.3}]
Silver
[{type=primary,name="John Johnson"},
{type=invoicing,name="Jane Johnson"}]
[7,8]
2222
Jane
[{invoice_id=125,item=blender, price=7456,discount=0.5},
Gold
[{type=primary,name="Jane Johnson"}
[5,6]
If you enable virtual table detection, the driver creates the following virtual tables:
CustomerTable
The main table uses the same name as the original table that it represents.
The following table shows the schema of CustomerTable virtual table:
id
Customer Name
Number of Invoices
Service Level
Number of Contacts
Number of Ratings
1111
John
2
Silver
2
2
2222
Jane
1
Gold
1
2
CustomerTable_Invoices
The following table shows the schema of CustomerTable_Invoices virtual table:
CustomerTable.id
Invoices_index
invoice_id
item
price
discount
1111
1
123
toaster
456
0.2
1111
2
124
oven
12345
0.3
2222
1
125
blender
7456
0.5
CustomerTable_Contacts
The following table shows the schema of CustomerTable_Contacts virtual table:
CustomerTable.id
Contacts_index
type
name
1111
1
primary
John Johnson
1111
2
invoicing
Jane Johnson
2222
1
primary
Jane Johnson
CustomerTable_Ratings
The following table shows the schema of CustomerTable_Ratings virtual table:
CustomerTable.id
Ratings_index
Ratings_value
1111
1
7
1111
2
8
2222
1
5
2222
2
6