如何在Cassandra中创建表

时间:2012-08-07 22:01:52

标签: cassandra

我正在检查WTF超级列,我试图让表格成为例子。 什么都没有出现。我很好奇如果格式看起来如何创建表。

    AddressBook = { // this is a ColumnFamily of type Super
                     phatduckk: {    // this is the key to this row inside the Super CF
                     // the key here is the name of the owner of the address book

                     // now we have an infinite # of super columns in this row
                     // the keys inside the row are the names for the SuperColumns
                     // each of these SuperColumns is an address book entry
                    friend1: {street: "8th street", zip: "90210", city: "Beverley Hills", state: "CA"},

    // this is the address book entry for John in phatduckk's address book
                    John: {street: "Howard street", zip: "94404", city: "FC", state: "CA"},
                     Kim: {street: "X street", zip: "87876", city: "Balls", state: "VA"},
                     Tod: {street: "Jerry street", zip: "54556", city: "Cartoon", state: "CO"},
                     Bob: {street: "Q Blvd", zip: "24252", city: "Nowhere", state: "MN"},
    ...
    // we can have an infinite # of ScuperColumns (aka address book entries)
                  }, // end row
    // all the address book entries for ieure
                      ieure: {     // this is the key to another row in the Super CF
                              joey: {street: "A ave", zip: "55485", city: "Hell", state: "NV"},
                       William: {street: "Armpit Dr", zip: "93301", city: "Bakersfield", state: "CA"},
},

}

我相信我必须创建列族和超列族。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

不要使用supercolumns,因为它们已被弃用。而是使用复合列,如下所示:

AddressBook {
    User1 {
        Friend1:street : "some st"
        Friend1:zip : 30000
        Friend1:city : "mayberry"
        Friend1:state : "ST"
        Friend2:street : "some other st"
        Friend2:zip : 30001
        Friend2:city : "springfield"
        Friend2:state : "ST"
    },
    User2 {
        ...
    }
}