Friday 15 January 2010

php - Designing/Using a user table in Cassandra for account creation and login -



php - Designing/Using a user table in Cassandra for account creation and login -

i'm new cassandra , i'm starting off designing simple user table business relationship registration , login purposes. pretty simple:

row key: time(); columns: email, name, password.

regarding simple structure, i've question:

here row key random one. how can login using email , password using php ?

cassandra takes query-based modeling approach, have same redundant, denormalized info in separate tables...and that's ok. you'll want maintain in-mind going forward.

registration , logging-in 2 different things, you're going want split up. thinking long-term queries , access patterns, makes sense split-up user business relationship info credential data, because credentials can change.

create table users ( userid uuid, firstname text, lastname text, email text, created_date timestamp, primary key (userid) ); create table usercredentials ( email text, password text, userid uuid, primary key (email) );

this way, when user changes password, won't impact overall users table. additionally, frequency users alter emails, occasional delete (and thus, generated tombstone) shouldn't big of deal. won't allow select * usercredentials email=? , password=? query work, you'll have select password usercredentials email=? instead, removes possibility of old passwords hanging around , causing potential issues. argue partitioning on email , clustering on password, doesn't create sense email never have more 1 password @ time (although design additional table store password history).

to maintain track of logins, i'd advise this:

create table logins ( time timestamp, userid uuid, email text, primary key (userid, time) );

this key rows combination of userid , time. difference here, userid partition key, logins each user stored together. time acts clustering key, perform order by operations on it. email payload field here, makes sense because can see while seamlessly grouping-together logins user might have changed email address. should cover underlying tables.

for coding side, codeigniter-phpcassa project might of help you.

php cassandra

No comments:

Post a Comment