101高考 SQL - 高考
By Xanthe
at 2014-05-15T01:39
at 2014-05-15T01:39
Table of Contents
小弟SQL觀念薄弱
作了很多題目都覺得似是而非...有點慌
請問一下(二)作答是否正確?
是否有更有效率的作法?
(三)沒有頭緒...請問此小題該如何作答
謝謝
=======================101高考二級=============================
二、考慮以下的討論版資料庫綱目(Database schema):
Member(mId, name, bDate, gender)
//會員編號,姓名,生日,性別
Article(mId, aId, title, content, postDate)
//會員編號,文章編號,標題,內容,張貼日期
Reply(mId, aId, rTime, content, responder)
//會員編號,文章編號,回覆日期時間,回覆內容,回覆者
若我們有以下的SQL敘述:
SELECT mId, name
FROM Member AS M
WHERE gender = ‘M’ AND
EXISTS
(SELECT *
FROM Article AS A
WHERE mId = M.mId AND (mId, aId) IN
(SELECT DISTINCT mId, aId
FROM Reply
WHERE mId = A.mId AND aId = A.aId
GROUP BY mId, aId
HAVING COUNT(*) > 10));
(二)以上查詢句的執行效率可能不佳,請指出造成其效率不佳的語法,並改寫成一個效率
較佳的敘述。(10分)
(三)針對你所改寫的查詢句,若想進一步提升其執行效率,請問可以建置那些索引(
Index)?請寫出建置這些索引的SQL敘述並說明原因。(10分)
============================================================================
擬作答:
(二)
SELECT mId, name
FROM Member AS M , Article AS A
WHERE gender = ‘M’ AND
A.mId = M.mId AND
(mId, aId) IN
(SELECT DISTINCT mId, aId
FROM Reply
WHERE mId = A.mId AND aId = A.aId
GROUP BY mId, aId
HAVING COUNT(*) > 10
)
);
--
作了很多題目都覺得似是而非...有點慌
請問一下(二)作答是否正確?
是否有更有效率的作法?
(三)沒有頭緒...請問此小題該如何作答
謝謝
=======================101高考二級=============================
二、考慮以下的討論版資料庫綱目(Database schema):
Member(mId, name, bDate, gender)
//會員編號,姓名,生日,性別
Article(mId, aId, title, content, postDate)
//會員編號,文章編號,標題,內容,張貼日期
Reply(mId, aId, rTime, content, responder)
//會員編號,文章編號,回覆日期時間,回覆內容,回覆者
若我們有以下的SQL敘述:
SELECT mId, name
FROM Member AS M
WHERE gender = ‘M’ AND
EXISTS
(SELECT *
FROM Article AS A
WHERE mId = M.mId AND (mId, aId) IN
(SELECT DISTINCT mId, aId
FROM Reply
WHERE mId = A.mId AND aId = A.aId
GROUP BY mId, aId
HAVING COUNT(*) > 10));
(二)以上查詢句的執行效率可能不佳,請指出造成其效率不佳的語法,並改寫成一個效率
較佳的敘述。(10分)
(三)針對你所改寫的查詢句,若想進一步提升其執行效率,請問可以建置那些索引(
Index)?請寫出建置這些索引的SQL敘述並說明原因。(10分)
============================================================================
擬作答:
(二)
SELECT mId, name
FROM Member AS M , Article AS A
WHERE gender = ‘M’ AND
A.mId = M.mId AND
(mId, aId) IN
(SELECT DISTINCT mId, aId
FROM Reply
WHERE mId = A.mId AND aId = A.aId
GROUP BY mId, aId
HAVING COUNT(*) > 10
)
);
--
Tags:
高考
All Comments
By Zanna
at 2014-05-19T09:30
at 2014-05-19T09:30
By Cara
at 2014-05-19T11:31
at 2014-05-19T11:31
By Lily
at 2014-05-21T09:37
at 2014-05-21T09:37
By Zanna
at 2014-05-23T01:47
at 2014-05-23T01:47
By Belly
at 2014-05-26T08:09
at 2014-05-26T08:09
By Ida
at 2014-05-29T11:08
at 2014-05-29T11:08
By Noah
at 2014-06-01T01:31
at 2014-06-01T01:31
By Daph Bay
at 2014-06-02T06:36
at 2014-06-02T06:36
By Blanche
at 2014-06-03T01:32
at 2014-06-03T01:32
By Callum
at 2014-06-04T02:02
at 2014-06-04T02:02
Related Posts
102高考律師 國際公法
By Selena
at 2014-05-14T22:18
at 2014-05-14T22:18
考場公布及准考證寄發時間
By Jack
at 2014-05-14T13:31
at 2014-05-14T13:31
TKB題庫班
By Brianna
at 2014-05-13T20:45
at 2014-05-13T20:45
如何準備國考圖資類科英文作文
By Odelette
at 2014-05-12T01:00
at 2014-05-12T01:00
關於考古題
By Skylar DavisLinda
at 2014-05-11T18:06
at 2014-05-11T18:06