database design - Moving from rational style modeling to NoSql/Cassandra style -


i trying change rational modeling cassandra modeling , need model following structure : have stores, promotions , prices . price list include items in specific store prices. promotion list include promotion details (e.g discount) , items included in promotion , relevant consumer clubs (e.g vip etc') stores id contain chain id, sub chain id, store id how lists items (per store):

<root>   <chainid>7290027600007</chainid>   <subchainid>001</subchainid>   <storeid>001</storeid>   <items count="2">     <item>       <itemcode>11210000094</itemcode>       <itemprice>12.80</itemprice>          </item>     <item>       <itemcode>11210000216</itemcode>       <itemprice>29.40</itemprice>     </item>     </items> </root> 

this how items list promotion :

<root>   <chainid>7290027600007</chainid>   <subchainid>001</subchainid>   <storeid>001</storeid>   <bikoretno>9</bikoretno>   <dllverno>8.0.0.0</dllverno>   <promotions count="1381">     <promotion>       <promotionid>168144</promotionid>       <discountrate>10000</discountrate>       <promotionitems count="3">         <item>           <itemcode>11210000094</itemcode>         </item>         <item>           <itemcode>7290011078806</itemcode>          </item>         <item>           <itemcode>7290011078807</itemcode>         </item>       </promotionitems>       <clubs>         <clubid>0</clubid>         <clubid>3</clubid>       </clubs>     <promotionstartdate>2015-01-31</promotionstartdate>     <promotionenddate>2015-12-31</promotionenddate>     </promotion> </promotions> </root> 

a frequent query can be:

for given list of items codes given store , consumer club fetch relevant item prices , relevant promotions

(i.e promotions contain @ least 1 item given list , consumer club , current date between startdate , enddate)

so each item price , optional relevant promotions (item can included in several promotions or none, , promotion includes @ least 1 item) how can model ? 1 option create each separate tables , connecting table (rational style) :

create table if not exists promos_with_items(                                promotionid varchar,                                promotion_item varchar,                                primary key(promotion_item,promotionid) ) comment='promotions items';  create table if not exists promos(                                chainid varchar,                                subchainid varchar,                                storeid varchar,                                promotionid varchar,                                start timestamp,                                end timestamp,                                discountrate double,                                discounttype int,                                clubs set<int>  ) comment='promotions';  create table if not exists item(                 chainid varchar,                 subchainid varchar,                 storeid varchar,                 itemid varchar,                 itemprice double); 

another option more cassandra style (but doesn't feel right ) single table :

create table if not exists items_with_promos(                                chainid varchar,                                subchainid varchar,                                storeid varchar,                                itemid varchar,                                itemprice double                                promotionid varchar,                                start timestamp,                                end timestamp,                                discountrate double,                                discounttype int,                                clubs set<int>                                                               ; 

but in case happens if item included in several promotions or if not included in promotion should key / index ? should chainid,subchainid,storeid,customer club,dates ?


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -