In the previous chapters you have learned how to create an OrientDB graph database using OrientDB Console. Now you should do some programming tasks yourself.
Which alternatives does OrientDB offer regarding a database schema?
Schema-less mode: Each vertex or edge may have different properties
Automatic-schema mode: OrientDB creates and updates a schema automatically when new vertices are inserted
Schema-full mode: All vertices of a vertex- or edge-class must have the same predefined structure
Schema-mixed mode: Some properties of a vertex- or edge-class are predifined, others may be added arbitrarily for each object
OrientDB offers a set of predefined schemas, e. g. Business, Routing, Finance or WaterSupply. You can choose one that fits for your problem.
OrientDB supports schema-less, schema-full and schema-mixed mode (see documentation for details)
Which tools or languages can you use to define a schema for OrientDB?
OrientDB Studio with a graphical user interface
OrientDB OXML Schema Creator
OrientDB Studio with SQL
OrientDB Console
Java with Tinkerpop Blueprints
Oracle designer
To define a schema for OrientDB you can use Studio with the Schema Manager or Studio with SQL 'Create Class' and 'Create Property' commands, OrientDB Console or in Java the createVertexType() and createEdgeType() methods.
Which is the correct syntax if you want to create a new vertex class "Account" using the Console with SQL?
create vertex class Account;
create class Account extends V;
create class Account under V;
create new vertex Account;
See documentation for CREATE CLASS
Which is the correct syntax if you want to create a new property "accountNr" of the OrientDB class "Account" using the Console with SQL?
alter class Account add (accountNr integer);
create property Account.accountNr integer;
create property accountNr integer;
create property accountNr in Account as integer;
See documentation for CREATE CLASS
You want to create the property "accountNr" of the OrientDB class "Account" which should exist for every record of the class and must not be empty (null). Which constraint(s) is/are necessary?
mandatory constraint
not null constraint
obligate constraint
both constraints: mandatory and not null
The mandatory constraint ensures that every record has a field accountNr but this field need not have a value. Not null means that if a field accountNr is present it must have a value other than NULL but there may be records without this field. Only both constraints together guarantee that each record has an accountNr with a value. There is no constraint "obligate".
You have created the class "Measure" with the properties "Length", "Width" and "Height". You want to use this class for a property "Size" in a class "Furniture". How should you create this property?
create property Furniture.Size EMBEDDED Measure;
create property Furniture.Size LINK Measure;
create property Furniture.Size DEPENDS ON Measure;
create property Size in Furniture of Measure;
Syntactically correct are "EMBEDDED" and "LINK". Here we use EMBEDDED because a measure is tightly connected to its furniture object and cannot be reused for another furniture object.