How to define a schema full mode for a class in OrientDB - orientdb

I am a new learner on OrientDB and have this question about schema. How to define a schema-full mode for a new class -say person class? Similarly how to define the schema-hybrid mode -using sql?
Somehow I can't make out this from the documentation.
Thanks,
DBuserN

The schema-full mode is controlled on a per-class basis and can be enabled or disabled using the STRICTMODE keyword. For example:
alter class Person strictmode=true;
For reference
http://orientdb.com/docs/2.0/orientdb.wiki/SQL-Alter-Class.html

Schema-full Enables strict-mode at a class-level and sets all fields as mandatory.
Schema-less Enables classes with no properties. Default is non-strict-mode, meaning that records can have arbitrary fields.
Schema-hybrid Enables classes with some fields, but allows records to define custom fields. This is also sometimes called schema-mixed.
You can define schema, as you create the structure of your DB. So if you define properties on a class it will be schema-full. A class without properties and it will be schema-less etc...
You can fine more information on official documentation.
Hope it helps.

Related

How to get all the fields from my model in Loopback 4

I have a MongoDB Collection with more then 400 fields, How can i get all the fields without defining each of them in the model. Right now i am only getting the fields that i have defined in the model. I have tried passing no arguments in the filter but still getting only the defined fields.
Thanks!
Disclaimer: I am a maintainer of LoopBack 4. The text below is cross-posted from our documentation in https://loopback.io/doc/en/lb4/Model.html#using-the-juggler-bridge, see also my pull request #1745 that introduced strict mode.
Models are defined primarily by their TypeScript class. By default, classes forbid additional properties that are not specified in the type definition. The persistence layer respects this constraint and configures underlying PersistedModel classes to enforce strict mode.
To create a model that allows both well-defined but also arbitrary extra properties, you need to disable strict mode in model settings and tell TypeScript to allow arbitrary additional properties to be set on model instances.
#model({settings: {strict: false}})
class MyFlexibleModel extends Entity {
#property({id: true})
id: number;
// Define well-known properties here
// Add an indexer property to allow additional data
[prop: string]: any;
}

How to set attribute value to instance of class at runtime

I'm on Enterprise Architect 14. I have a component diagram containing an interface User and two classes Employee and Customer, which both realize interface User.
Furthermore I created two instances, one of each class and specified the values of the attributes via Features & Properties > Set Run State....
Next I created a component with 2 attributes, one of type Employee and one of type Customer. Then I created an instance of the component.
Now I would like to set run state of the component instance by assigning ArbitraryUser to the Employee attribute and ArbitraryCustomer to the Customer attribute of the component instance. According documentation this should be possible (see here).
At run-time, an Object instance can have specific values for its attributes, or exist in a particular state. To model the varying behavior of Objects at run-time, use instance values selected from the 'Select ' dialog and run-time states or run-states.
However I could not figure out how to do so. Can someone help me?
AFAIK that is not possible.
I'm not sure what the quote from the help really means, but I've only ever been able to type a value for the run state.
An partial alternative would be to use associations rather than attributes to model such relations. Then you can create a link as an instance of the association to relate instances of Employee or Customer with instances of a ArbitraryComponent.
This solution doesn't work for datatypes, but it seems a bit far fetched to start modelling instances of datatypes.

OrientDB auto creation of vertex/edge schema classes

As far as I can tell there is no way to specify that an existing schema class should be used when a matching label is specified but default to the general V/E classes otherwise. I have few custom E sub classes that I would like to use but I don't want other edge labels to cause the creation of additional sub classes. The API I'm using is TinkerPop-based and I cannot explicitly specify vertex/edge classes.
The OrientConfigurableGraph.setUseClassForEdgeLabel(boolean) setting is an all or nothing option. If it is set to true schema classes are created for all labels and if it is set to false new vertex/edge instances are set to the general V/E classes even if there is a matching class. Am I correct about this? I would like a configuration option that allows the use of matching schema classes if they are available in the schema but without automatically creating others when there is no match. I'm using version 2.1.8.
After browsing the OrientDB v2.1.x reference documentation and javadocs, i couldn't find a configuration option that configures the graph the way you want, so what you can do, is to open a ticket in the issue tracker at github and request that feature.
Although, in the meantime, you can control this programatically with the Graph API with the custom vertex/edges functions, as explained in the documentation, not ideal, as you need to control this programatically, but for now is the closest i could find.

Does SQL Table name === Class name? and vice-versa?

So I'm just learning Cache, and have a question about tables, classes and globals, what's the difference?
I'm doing the tutorial and it seems like, since this is an object-orientated DB that a class is a table and vice versa. So if I create a class and make it persistent with properties, I can use SQL to query it. Is this true? What's a global then?
Reason I ask is because I'm using Management portal for one of our Cache applications and although I can see a table in WinSQL and Documatic, that same table doesn't seem to exist in the class explorer (Under management portal)... can't figure it out, is it hidden? Is there a command to see class def'ns in terminal??
thanks!
In Caché, classes are tables and tables are classes. You can choose when you want to use SQL access and when you want to use Object Oriented access.
Globals are the sparse multidimensional arrays which sit as storage beneath the class/table. Look at the storage definition at the end of your class to see the actual globals that your persistent class is stored in (e.g. ^Sample.PersonD)
By default, class names are projected as table names, but there are some rules which apply in order to ensure that the table names comply with SQL standards:
if you have a class that is a couple of packages deep (e.g. MyApp.Data.Person) then all but the last "." will be replaced by "_" in the table name (e.g. MyApp_Data.Person would be the table name)
You can't use reserved SQL keywords in table names, so if you make something in the User package for example (class: User.Person) then Caché will change the Package name (e.g. SQLUser.Person would be the name of the table)
I suggest you refer to http://docs.intersystems.com/cache20141/csp/docbook/DocBook.UI.Page.cls?KEY=GORIENT_ch_persistence for more detail

MS EntityFramework: how to split entity with inheritance? Using of discriminator

I have table name Transaction in the DB. I want to have 2 subclasses TransactionA and TransactionB. I've made it as described here: http://www.robbagby.com/entity-framework/entity-framework-modeling-table-per-hierarchy-inheritance/comment-page-1/#comment-607
The problem is I need to use the field that is discriminator here (see the example, it's PersonCategory there). But it has to be deleted after that I cannot use it.
How to solve this problem?
Thanks
If it is a discriminator its only usage is to map record to either TransactionA or TransactionB. It cannot be set in the application. It is set if you insert TransactionA instance or TransactionB instance and record. It also cannot be updated because object of one type cannot change to object of other type - if you need such logic you cannot model it as inheritance.
Yes it is used as a EF helper to identify type of the specific type of the object. One disadvantage is that approach is every field should be a nullable field and tables are not normalized. However, no joins are involved hence, it is fast approach. Table per type is relatively good approach you have two classes TransactionA and TransactionB with generic class called Transaction.Although, you have to do join as a result of that, performance is not that great compair to earlier approach.