My problem is that  my composite primary key can change, like shown here :
1 - Root ---> Project 1 --> Cluster 1 ---> Cluser 2 -->  Building 1 -->  Sensor 
1
2- Root ---> Project 2-->  Building 1 -->  Sensor 1
3- Root ---> Building 3 -->  Sensor 1
4- Root ---> Floor 3 -->  Sensor 1


In some graph I don’t have  Cluster which means if I have a composite primary 
key with ( Root, project , cluster, building, Floot ,sensor) and in some rows I 
don’t have floors or in some I don’t have clusters that will be bad, or even 
worse if I have a new type like Zone how can I add that , some  what I want is 
to have all my graph in a field so I can do something like : R1#P1#C1#B2.
So I thought if this is a bad idea or can It work ?

De : Ciureanu Constantin [mailto:ciureanu.constan...@gmail.com]
Envoyé : jeudi 22 septembre 2016 12:57
À : user@phoenix.apache.org
Objet : Re: Primary key with a separator

But Phoenix does this for you (creates a composite key, special separator) - 
you just have to specify the PK while creating the table.

CREATE TABLE IF NOT EXISTS us_population (

      state CHAR(2) NOT NULL,

      city VARCHAR NOT NULL,

      population BIGINT

      CONSTRAINT my_pk PRIMARY KEY (state, city));
from http://phoenix.apache.org/Phoenix-in-15-minutes-or-less.html

Take care that the PK fields will be placed in the HBASE table row keys - and 
would dramatically speed up the scans, all other fields would be accessible via 
filters (full partition scan) in case you still know a range of keys (use PK 
wisely for that).

2016-09-22 10:38 GMT+02:00 AZELMAT Hamza 
<hamza.azel...@batiment.setec.fr<mailto:hamza.azel...@batiment.setec.fr>>:

I’m designing a nosql database with hbase and phoenix, and i was thinking of 
making a composite primary key in this form.

HbaseRowKey (path_id,sensor_id,date) and C.Value ( Column Family).

my path_id will be composed like this : R1#P1#C1#B2.

and i was thinking with a SQL request without knowning R1 and P1 and C1 can i 
get all Rows with path_id containing B2 with a substring ? will it be very 
costly in Phoenix ?
To be more specific this is an iot project and we have use cases like this :

Root ---> Project 1 --> Cluster 1 ---> Cluser 2 -->  Building 1 -->  Sensor 1
Root ---> Project 2-->  Building 1 -->  Sensor 1
Root ---> Building 3 -->  Sensor 1
Root ---> Floor 3 -->  Sensor 1

I May have growing new type of nodes, that’s why I want something flexible in 
my composite primary Key , R1 will be the root id, P1 the project with ID 1 etc 
..

So I have requests like getting all sensors data of building with ID 1  with 
this kind of conception do you think it’s a costly method ?

I have thought of neo4j but I like the easy of use of phoenix with SQL, also 
it’s free of use and open source .

Thank you for your help


Reply via email to