Once created, a database schema can be updated, to add or remove attributes, add or remove classes or schema, add indexes or contraints.
? for (x in 1 <= 50000) new Person(firstname : "xx" + string(x)); ? select Person.firstname = "xx20"; = bag(23336.2.420154:oid) ? select Person.firstname = "xx10"; = bag(23316.2.824639:oid)The first operation creates 50000 person instances: as you can notice, this operation takes a few seconds. The two last operations query person instance according to their firstname attribute. These operations also take a few seconds to perform and take a significant amount of CPU.
class Person {
string firstname;
char lastname;
int age;
Address addr;
...
set<Person *> children;
index on firstname;
index on lastname;
index on age;
};
% eyedbodl -d foo -u person.odl Updating 'person' schema in database foo... Creating [NULL] hashindex 'index<type = hash, propagate = on> on Person.firstname' on class 'Person'... Creating [NULL] hashindex 'index<type = hash, propagate = on> on Person.lastname' on class 'Person'... Creating [NULL] btreeindex 'index<type = btree, propagate = on> on Person.age' on class 'Person'... Done
% eyedboql -d foo -w ? select Person.firstname = "xx20"; = bag(23336.2.420154:oid) ? select Person.firstname = "xx10"; = bag(23316.2.824639:oid)and you will notice that these operations are immediate.
In the same way, you can add a notnull and an unique constraint on the lastname attribute within the class Person:
class Person {
string firstname;
string lastname;
int age;
Address addr;
...
index on firstname;
index on lastname;
index on age;
constraint<notnull> on lastname;
constraint<unique> on lastname;
};
% eyedbodl -d foo -u person.odl Updating 'person' schema in database foo... Creating [NULL] notnull_constraint 'constraint<notnull, propagate = on> on Person.lastname' on class 'Person'... Creating [NULL] unique_constraint 'constraint<unique, propagate = on> on Person.lastname' on class 'Person'... Done
% eyedboql -d foo -w ? new Person(lastname : "curtis"); = 79902.2.884935:oid ? new Person(lastname : "curtis"); near line 2: 'new Person(lastname : "curtis")' => oql error: new operator 'new<oql$db> Person(lastname:"curtis"); ' : unique[] constraint error: attribute path 'Person.lastname'.or with no lastname attribute:
? new Person(); near line 3: 'new Person()' => oql error: new operator 'new<oql$db> Person(); ' : notnull[] constraint error: attribute path 'Person.lastname'.
It is possible to remove a class in a schema using eyedbodl. For instance, to remove the class Employee in the already introduced schema:
% eyedbodl -d foo -u --rmcls=Employee Updating 'UNTITLED' schema in database foo... Removing class Employee DoneYou can then check the class removal by:
% eyedbodl -d foo --gencode=ODL
//
// EyeDB Version 2.8.4 Copyright (c) 1995-2007 SYSRA
//
// UNTITLED Schema
//
// Generated by eyedbodl at Mon Dec 10 13:44:03 CET 2007
//
class Address (implementation <hash, hints = "key_count = 2048;">) {
attribute int32 num;
attribute string street;
attribute string town;
attribute string country;
};
class Person (implementation <hash, hints = "key_count = 2048;">) {
attribute string firstname;
attribute string lastname;
attribute int32 age;
attribute Address addr;
relationship Person* spouse inverse Person::spouse;
attribute set<Person*> children;
index<type = hash, hints = "key_count = 4096; initial_size = 4096; extend_coef = 1; size_max = 4096;", propagate = on> on Person.firstname;
index<type = hash, hints = "key_count = 4096; initial_size = 4096; extend_coef = 1; size_max = 4096;", propagate = on> on Person.lastname;
constraint<unique, propagate = on> on Person.lastname;
constraint<notnull, propagate = on> on Person.lastname;
index<type = btree, hints = "degree = 128;", propagate = on> on Person.age;
};
It is as well possible to remove entirely the database schema:
% eyedbodl -d foo -u --rmsch Updating 'UNTITLED' schema in database foo... Removing [2570.2.500986:oid] hashindex 'index<type = hash, hints = "key_count = 4096; initial_size = 4096; extend_coef = 1; size_max = 4096;", propagate = on> on Person.firstname' from class 'Person'... Removing [2585.2.286352:oid] hashindex 'index<type = hash, hints = "key_count = 4096; initial_size = 4096; extend_coef = 1; size_max = 4096;", propagate = on> on Person.lastname' from class 'Person'... Removing [2599.2.7912:oid] btreeindex 'index<type = btree, hints = "degree = 128;", propagate = on> on Person.age' from class 'Person'... Removing [2625.2.396262:oid] unique_constraint 'constraint<unique, propagate = on> on Person.lastname' from class 'Person'... Removing [2620.2.240536:oid] notnull_constraint 'constraint<notnull, propagate = on> on Person.lastname' from class 'Person'... Removing class Address Removing class Person Removing class set<Person*> DoneThe result can be checked with:
% eyedbodl -d foo --gencode=ODL // // EyeDB Version 2.8.4 Copyright (c) 1995-2007 SYSRA // // UNTITLED Schema // // Generated by eyedbodl at Mon Dec 10 13:44:03 CET 2007 //
EyeDB manual