0
我試圖創建一些表,具有以下特點:如何輕鬆獲取所有密鑰的最新版本的數據?
- 存儲數據的所有版本的特定鍵
- 能夠很容易地獲得最新的數據版本的所有鍵
我的架構如下:
CREATE TABLE WebSitesStatus(
-- Host name of the site in question.
Host String(40) NOT NULL,
-- When the information on the site was last updated.
UpdateDate Date NOT NULL,
HttpsWorks BOOL NOT NULL,
ModernTls BOOL NOT NULL,
) PRIMARY KEY(Host, UpdateDate DESC);
所以表的例子子集可能是:
+--------------+------------+------------+-----------+
| Host | UpdateDate | HttpsWorks | ModernTls |
+--------------+------------+------------+-----------+
| foobar.com | 2016-10-14 | true | false |
| google.com | 2016-10-14 | true | true |
| google.com | 2016-04-23 | false | false |
| nytimes.com | 2016-10-14 | false | false |
| nytimes.com | 2016-05-25 | true | true |
| nytimes.com | 2016-04-25 | true | false |
| nytimes.com | 2016-04-23 | true | false |
| paypal.com | 2016-10-14 | true | false |
+--------------+------------+------------+-----------+
我想找到一種方法來找回
+--------------+------------+------------+-----------+
| Host | UpdateDate | HttpsWorks | ModernTls |
+--------------+------------+------------+-----------+
| foobar.com | 2016-10-14 | true | false |
| google.com | 2016-10-14 | true | true |
| nytimes.com | 2016-10-14 | false | false |
| paypal.com | 2016-10-14 | true | false |
+--------------+------------+------------+-----------+
但結構並不讓我很容易地做到這一點。有沒有辦法輕鬆地做這個查詢?