官术网_书友最值得收藏!

When to use static columns

We've now seen two ways to model users, each of whom has many status updates. The first approach was simply to define a table for users and a table for their status updates; the relationship between the two is encoded in the key structure of user_status_updates. The second approach is to store all of the information in one users_with_status_updates table using static columns to associate user-level data with the username partition key rather than having a different value for each clustering column. Which is better?

The answer largely depends on how closely coupled the related data types are. If we expect that most of our interactions with user profile information will also involve interacting with the user's status updates, and vice versa, then it makes a lot of sense to store them together in one table. The reasoning is similar to the parent-child conceptual framework discussed earlier, but in reverse. Not only is the user a special relationship from the standpoint of the status update, but also the status update is a special relationship from the standpoint of the user.

In the case of MyStatus, on balance, the relationship between users and status updates doesn't quite pass this test. In subsequent chapters, we'll expand our schema to accommodate several different one-to-many relationships where the user plays the role of parent. It's not clear that the relationship between users and status updates is more fundamental than the other relationships that we will model for users.

For this reason, we'll continue to work with the users and user_status_updates tables and leave behind the users_with_status_updates table as an interesting exercise.

主站蜘蛛池模板: 突泉县| 大姚县| 永宁县| 孙吴县| 杨浦区| 股票| 绥芬河市| 梨树县| 大足县| 土默特右旗| 浦东新区| 双桥区| 平定县| 资中县| 临夏县| 姜堰市| 彰化市| 武夷山市| 阳东县| 海丰县| 华亭县| 望都县| 罗平县| 惠来县| 重庆市| 漳平市| 合山市| 吉隆县| 岗巴县| 慈利县| 九江市| 通榆县| 静乐县| 保德县| 尉犁县| 桓仁| 湟中县| 吴旗县| 胶南市| 韶山市| 余江县|