2

Is there a "view" equivalent on orientdb?

I have a rdbms background and am looking for a way to save a query as an object which i can query directly.

Take for example the following query SELECT mobile_number AS mobile_number, verifications.verification_code[0] AS verification_code, verifications.is_verified[0] AS is_verified, Max(verifications.active_devices .@ rid) AS device_rid, verifications.active_devices .@ version AS active_version FROM guests

I would like to create a "view" with this query called verified_guests, then I would like to execute a query against verified_guests using something like select from verified_guests

In the rdbms world, I would be able to do the following create view verified_guests as SELECT mobile_number AS mobile_number, verifications.verification_code[0] AS verification_code, verifications.is_verified[0] AS is_verified, Max(verifications.active_devices .@ rid) AS device_rid, verifications.active_devices .@ version AS active_version FROM guests

then I would be able to select * from verified_guests.

Does orientdb have an equivalent or an alternative to this?

Any guidance is appreciated.

Thanks,

1 Answers1

1

I made this schema to reproduce your issue:

create class guests extends V
create property guests.mobile_number integer
create property guests.name string

enter image description here

try this:

create class verified_guests extends V
INSERT INTO verified_guests FROM SELECT mobile_number, name FROM guests

this is the result:

select * from verified_guests

enter image description here

Hope it helps.

Regards.

Michela Bonizzi
  • 2,622
  • 1
  • 9
  • 16
  • In RDBMS a view is just a query. If you add/delete/update records in any of the underlying tables and the view automatically reflects those changes. That is not happening in this example. I tried this in OrientDB and verified_guests does not automatically pull in additions to guests. What you have shown is not at all like a view in a SQL database. Or am I missing something? – Huliax Feb 27 '19 at 16:17