Hide or Omit Identifying Key Fields
Hide or omit identifying key fields from nested objects when Oracle AI Database can derive the key value.
You can hide or omit identifying key fields from nested objects when Oracle AI Database can derive the key value. The value is automatically derived by the database when possible - using matching values from selected parent or child tables, an alternate unique, or by querying the database with other available unique or foreign key fields.
The following GraphQL definition hides team_id from the nested team object:
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW
team_lineup_dv AS
driver @update {
_id : driver_id,
driverName : name,
driverPoints : points,
team @update {
team_id @hidden,
teamName : name,
teamPoints : points
}
};
The following SQL definition uses HIDDEN for the same field:
CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW team_lineup_dv AS
SELECT JSON {
'_id' : d.driver_id,
'driverName' : d.name,
'driverPoints' : d.points,
'team' :
( SELECT JSON {
'team_id' : t.team_id HIDDEN,
'teamName' : t.name,
'teamPoints' : t.points
}
FROM team t WITH UPDATE
WHERE t.team_id = d.team_id )
}
FROM driver d WITH UPDATE;
Note: Identifying key fields cannot be hidden or omitted for the root object. If an identifying key field is hidden or omitted, then it cannot be updated through the duality view. If an inserted or updated document includes a hidden or omitted identifying key field, then an error is raised.
When an identifying key or part of an identifying key is omitted from the view definition, and the key cannot be derived from child or parent objects, use IDENTIFIED BY to specify the identifying key for that table.