Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About DB integrity [moved] #455

Closed
lvca opened this issue Dec 10, 2012 · 4 comments
Closed

About DB integrity [moved] #455

lvca opened this issue Dec 10, 2012 · 4 comments

Comments

@lvca
Copy link
Member

lvca commented Dec 10, 2012

This is Issue 455 moved from a Google Code project.
Added by 2011-06-22T05:02:42.000Z by evgs...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Low, v2.1

Original description

Hi Luca,
I care about db integrity, escpecially about lost links.
We can save any link (#x:y) to any place. OrientDB does not care if address exists now.
It would be nice if OrientDB has mode which supports integrity.
I offer to have one global index (references) which contains master and details links.
Now before saving of record is necessary 
1. Collect all links which records has
2. Check if all are exist
3. Update index:references for this record

It is not necessary to care which field has link to master record. It is enough just to know that link exists

Before record deleting we can check if index:references has links to this record

Example 

create class A;
insert into A (f) values ('Rec1'); // #5:1
insert into A (f) values ('Rec2'); // #5:2
insert into A (f) values ('Rec3'); // #5:3

create class B;
insert into B (f,A) values (1,#5:1); // #6:1
// Need to check if #5:1 exists
// insert into index:references (key,rid) values (#5:1,#6:1)

insert into B (f,A,A1) values (1,#5:1,#5:2); // #6:2
// Need to check if #5:1 and #5:2 exist
// insert into index:references (key,rid) values (#5:1,#6:2)
// insert into index:references (key,rid) values (#5:2,#6:2)

delete from A where f like "Rec%"
// Collect RIDs of records which should be deleted (#5:1,#5:2,#5:3)
// select from index:references where key in (#5:1,#5:2,#5:3)
// now if selection from references does not contains any records we can realize deteting

So it is possible to support DB integrity without schema.

Evgeny 

P.S.
This is can be more complicated if remember that indexes do have links too.
Also as I have read OrientDB will support version of records.
@lvca lvca added this to the 2.2 milestone Oct 2, 2014
@lvca lvca modified the milestones: 2.2.0-beta, 2.2.0-rc1 Dec 13, 2015
@lvca lvca modified the milestones: 2.2.0-rc1, 2.2.0 GA May 7, 2016
@lvca
Copy link
Member Author

lvca commented May 7, 2016

This is not needed anymore if you use graph api.

@lvca lvca closed this as completed May 7, 2016
@lvca lvca removed this from the 2.2.0 GA milestone May 7, 2016
@PhantomYdn
Copy link
Contributor

If somebody needed there is the following implementation of a hook for consistency support without graph api: https://github.com/OrienteerDW/Orienteer/blob/master/orienteer-core/src/main/java/org/orienteer/core/hook/ReferencesConsistencyHook.java

@smolinari
Copy link
Contributor

Thanks Ilia @PhantomYdn.

How would that work out on performance?

Scott

@PhantomYdn
Copy link
Contributor

Optimized, but still might be not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants