OrientDB is "schema-less" by default. You may not understand the meaning of defined properties. All properties are returned in select statements. It does not filter the results based on property definitions. Properties are used as constraints for inserts and updates. They are also used when defining indexes.
Using my example. here are the results of the select on Person. Notice that the properties are returned regardless of the property definitions. Also note that you can add any arbitrary property name and value to a person and it will be returned as well. Properties on vertices do not require property definitions on classes. This is the schema-less behavior. I'm not sure that this is properly explained in the documentation ( http://orientdb.com/docs/last/Java-Schema-Api.html) which makes it sound like there's actually a Schema full "mode" but there isn't. If you don't define any properties on a class, then it's schema-less. If you define some properties as mandatory on a class, then it's schema-hybrid. If you define all properties as mandatory on a class, then it's nearly schema-full except that you can still add arbitrary property name/values to a vertex. In other words, you can't prevent property name/values from being part of a vertex. You can only require some of them using mandatory=true. You might ask what the use of mandatory=false. Well, properties are used when creating indexes so there will be cases were you don't want the property to be mandatory but you still want to use it in an index. select from Person +----+-----+------+------+----+------+ |# |@RID |@CLASS|gender|name|salary| +----+-----+------+------+----+------+ |0 |#49:2|Person|female|Jill| | |1 |#50:1|Person|male |Sam |400 | +----+-----+------+------+----+------+ Note that you can still create property name/values on a vertex without actually defining a property on the class. e.g: create vertex Person set name="Rena",gender="female",role="manager",cars=5,favoriteColor="green" select from Person +----+-----+------+------+----+------+-------+----+-------------+ |# |@RID |@CLASS|gender|name|salary|role |cars|favoriteColor| +----+-----+------+------+----+------+-------+----+-------------+ |0 |#49:2|Person|female|Jill|500 | | | | |1 |#49:3|Person|female|Rena| |manager|5 |green | |2 |#50:1|Person|male |Sam |500 | | | | +----+-----+------+------+----+------+-------+----+-------------+ On Friday, August 5, 2016 at 7:22:58 AM UTC-4, parvat wrote: > > so if i do select from Person it will return all the not mandatory fields > rite > > On Thursday, August 4, 2016 at 9:29:11 AM UTC+5:30, odbuser wrote: >> >> Is this what you are looking for? You can mix schema-full and >> schema-less behavior. I think the MANDATORY constraint is what you are >> looking for. >> >> create class Person extends V; >> create vertex Person; >> create property Person.name STRING (MANDATORY TRUE,NOTNULL); >> create property Person.gender STRING (MANDATORY TRUE,NOTNULL); >> create property Person.salary INTEGER (MANDATORY FALSE,NOTNULL); >> >> This means that name and gender are required and can't be null. >> Salary is optional but when set it can't be null. >> >> The following will work: >> create vertex Person set gender="female",name='Jill' >> create vertex Person set gender="male",name='Sam',salary=400 >> >> The following will fail: >> create vertex Person >> create vertex Person set name='Frank' >> create vertex Person set salary=null,gender="female",name='Jill' >> >> >> On Wednesday, August 3, 2016 at 4:02:42 AM UTC-4, parvat wrote: >>> >>> Hi, Can you help me on the below question >>> >>> Can a define different properties to the vertex having same label's >>> >>> Example: >>> Person with name,age ,gender >>> Person With name,gender ,salary >>> >>> Here Person is the Vertex name. >>> >>> >>> Ideally i want to have a schema less nature . >>> >> -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
