NEO4J

A. CONSTRAINT

#NODE constraint
Property existence constraints and Node Keys are only available in Neo4j Enterprise Edition. Note that databases with property existence constraints and/or Node Keys cannot be opened using Neo4j Community Edition.

example : CREATE CONSTRAINT ON (book:anggota) ASSERT book.noang IS UNIQUE
artinya tidak boleh ada nama yg sama untuk label book.noang

note : jika remote book.isbn mka eror :Node(0) with label `Book` must have the property `noang`, artinya noang adalah unique tidak bisa delete unique

#DROP UNIQUE CONSTRAINT

 DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE

#relationship property existence constraint
label test , propertisnya :nama,kode,namakel
label testcons , propertisnya : hp,alamat, kode
yg mnjadi fk : kode
artinya membuat contraint untuk test.kode

CREATE CONSTRAINT ON ()-[a:test]-() ASSERT exists(a.kode)
membuat join onotoone antara label test dengan testcons:
 CREATE (a:testcons {hp:"0987", alamat:"alamt2", kode:"002"} )-[s:test {kode:"row2"}]->(v:test {nama:"nama2", namakel:"hj", kode:"002"})
query diatas akan membuat data untuk dua label test dan label testcons : dan akan membuat relasi dengan nama test , dengan relasi test kode="row2";
perhatikan kode pada relasi test : atau image


jika tampa relasi dengan constraint kode pada relasi, maka akan eror, perhtaikan :
 CREATE (a:testcons {hp:"123", alamat:"alamt3", kode:"003"} )-[s:test]->(v:test {nama:"nama3", namakel:"kel3", kode:"003"})
terlihat ada eor, relasi test dengan properties kode tidak ada,
bolehkan nama propertis relasi sama? jawaban boleh,
berikut data yg ditampilkan :
#menampilkan relasi degan dengan nama relasi test,
menampilkan relasi testt dengan properties  kode="row2"



https://neo4j.com/docs/cypher-manual/current/schema/constraints/



Share on Google Plus

About riki aldi pari

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 komentar:

Posting Komentar