воскресенье, 8 июля 2012 г.

OrientDB - create new table (class or object)

First way

1. To create new object or class simple call:
orientdb>  create class person

2. Then we need to define what properties of object person we need to store
create property person.firstname STRING
create property person.lastname STRING
create property person.middlename STRING
create property person.age INTEGER
create property person.birthdate DATE
create property person.country STRING
create property person.city STRING
create property person.address STRING
create property person.email STRING
create property person.phone STRING
create property person.ssn STRING

3. Then if we need that some field of object (class) must be unique then we define index
orientdb> create index person.ssn UNIQUE


orientdb>CREATE INDEX persons ON person (ssn, email, pnone) UNIQUE

Second way

1. To dynamically create new object it is possible to point out property names and values directly

orientdb> create class group
orientdb> insert into group (name, description) values ('employee','Internal personnel')

orientdb> browse class group

  #| RID     |name                |description
  0|     #9:0|employee            |Internal personnel

2. To make name of group unique we must define property name and index
orientdb> create property group.name STRING
orientdb> create index group.name UNIQUE

Комментариев нет:

Отправить комментарий