Database design 这是设计无sql数据库的好方法吗?
我对关系数据库有足够丰富的经验,但不想尝试SQL one(键值)。并为此制定了一项任务。这是另一个关于用户、活动和统计数据分组的较短链接。当然,它必须在高负载下工作=) 用例:Database design 这是设计无sql数据库的好方法吗?,database-design,nosql,key-value-store,Database Design,Nosql,Key Value Store,我对关系数据库有足够丰富的经验,但不想尝试SQL one(键值)。并为此制定了一项任务。这是另一个关于用户、活动和统计数据分组的较短链接。当然,它必须在高负载下工作=) 用例: 1. Generate short link 1.1. User is not logged, without a campaign. Put a pair to the bucket LINKS, don't put to USERS and CAMPAIGNS buckets. 1.2. User is logg
1. Generate short link
1.1. User is not logged, without a campaign.
Put a pair to the bucket LINKS, don't put to USERS and CAMPAIGNS buckets.
1.2. User is logged, without a campaign.
Put the pair to LINKS, update a counter in the bucket USERS, don't put to CAMPAIGN bucket.
1.3. User is logged and campaign is created.
Put/update pairs to all the buckets.
我是如何用关系数据库解决这个任务的。四个表格:
- 用户(id、姓名)李>
- 活动(所有者id、id、名称)李>
- url(短url、活动id、长url)李>
- 统计信息(短URL、获取计数器、创建时间、最后访问时间)
2. Get statistics.
2.1. Get all links and its stats by user (must be logged).
2.2. Get all links and its stats by campaign (must be logged).
2.3. Get stats by short url (must be logged).
3. Redirect to a long url by short one (no matter logged user or not).
/.
|--- (b) USERS --- (k) user_id
| --- (v) { "name": "User", "settings": {}, "stats": {"link_count": 1}, "links": ["a","b"]}
|--- (b) LINKS --- (k) short_link
| --- (v) { "long_link": "https://example.com", "stats" : {"counter": 1, "created_at": "2019-01-01T00:00:00Z, "last_access_at": "2019-01-01T00:00:01Z"}}
|--- (b) CAMPAIGNS --- (b) USER_ID --- (k) campaign_id
| --- (v) { "name": "campaign", "links": ["a", "b"]}