100普考資料處理 - 普考
By Hardy
at 2013-06-21T21:44
at 2013-06-21T21:44
Table of Contents
[考題] 國考歷屆考題與考題觀念討論(書裡看到的選這個)請附上想法、出處
五、假設某圖書館之關聯資料庫中有七個關聯資料表,其資料綱要(data schema)如下,
底線代表主要鍵。
BOOK(BookId, Title, PublisherName)
BOOK_AUTHORS(BookId, AuthorName)
PUBLISHER(Name, Address, Phone)
BOOK_COPIES(BookId, BranchId, No_Of_Copies)
BOOK_LOANS(BookId, BranchId, CardNo, DataOut, DueDate)
LIBRARY_BRANCH(BranchId, BranchName, Address)
BORROWER(CardNo, Name, Address, Phone)
寫出以下查詢之 SQL:(40分)
(一)該圖書館的所有分館各擁有多少本書名為“三國演義”的書?
(二)現在那些借閱人在各分館借出“三國演義”這本書?
(三)現在那些借閱人在各分館有逾期未還的書?
(四)該圖書館擁有多少不同的書籍?
這題小弟在對某補習班的答案時發現補習班的答案跟我的有很大的落差
不知道是小弟我自己觀念不清楚還是補習班答案錯了,所以PO上來與各位
高手們討論~希望各位高手們賜教~謝謝~
以下是小弟的寫法:
------------------------------------------------------------------
(一) SELECT LI.BookId,LI.BranchName,No_Of_Copies
FROM BOOK,BOOK_COPIES AS CP,LIBRARY_BRANCH AS LI
WHERE BOOK.BookId=CP.BookId AND
CP.BranchId=LI_BRANCH.BranchId AND
Title="三國演義"
GROUP BY LI.BranchId,LI.BranchName;
[註]假設No_Of_Copies是重複書的數量
(二) SELECT DISTINCT CardNo,Name
FROM BOOK,BOOK_LOANS,BORROWER
WHERE BOOK.BookId=BOOK_LOANS.BookId AND
BOOK_LOANS.CardNo=BORRPW.CardNo AND
Title="三國演義";
[註]假設可能有借閱者在不同分館借閱相同的書
(三) 此小題使用SQL SERVER語法查詢:
SELECT CardNo,Name
FROM BOOK_LOANS,BORROWER
WHERE BOOK_LOANS.CardNo=BORROWER.CardNo AND
GETDATE() > DueDate;
(四) SELECT COUNT(BookId)
FROM BOOK_COPIES;
[註]假設1.不同的書會有不同的BookId
假設2.可能有書圖書館沒有收藏但把書的資料先建到資料庫中
--
五、假設某圖書館之關聯資料庫中有七個關聯資料表,其資料綱要(data schema)如下,
底線代表主要鍵。
BOOK(BookId, Title, PublisherName)
BOOK_AUTHORS(BookId, AuthorName)
PUBLISHER(Name, Address, Phone)
BOOK_COPIES(BookId, BranchId, No_Of_Copies)
BOOK_LOANS(BookId, BranchId, CardNo, DataOut, DueDate)
LIBRARY_BRANCH(BranchId, BranchName, Address)
BORROWER(CardNo, Name, Address, Phone)
寫出以下查詢之 SQL:(40分)
(一)該圖書館的所有分館各擁有多少本書名為“三國演義”的書?
(二)現在那些借閱人在各分館借出“三國演義”這本書?
(三)現在那些借閱人在各分館有逾期未還的書?
(四)該圖書館擁有多少不同的書籍?
這題小弟在對某補習班的答案時發現補習班的答案跟我的有很大的落差
不知道是小弟我自己觀念不清楚還是補習班答案錯了,所以PO上來與各位
高手們討論~希望各位高手們賜教~謝謝~
以下是小弟的寫法:
------------------------------------------------------------------
(一) SELECT LI.BookId,LI.BranchName,No_Of_Copies
FROM BOOK,BOOK_COPIES AS CP,LIBRARY_BRANCH AS LI
WHERE BOOK.BookId=CP.BookId AND
CP.BranchId=LI_BRANCH.BranchId AND
Title="三國演義"
GROUP BY LI.BranchId,LI.BranchName;
[註]假設No_Of_Copies是重複書的數量
(二) SELECT DISTINCT CardNo,Name
FROM BOOK,BOOK_LOANS,BORROWER
WHERE BOOK.BookId=BOOK_LOANS.BookId AND
BOOK_LOANS.CardNo=BORRPW.CardNo AND
Title="三國演義";
[註]假設可能有借閱者在不同分館借閱相同的書
(三) 此小題使用SQL SERVER語法查詢:
SELECT CardNo,Name
FROM BOOK_LOANS,BORROWER
WHERE BOOK_LOANS.CardNo=BORROWER.CardNo AND
GETDATE() > DueDate;
(四) SELECT COUNT(BookId)
FROM BOOK_COPIES;
[註]假設1.不同的書會有不同的BookId
假設2.可能有書圖書館沒有收藏但把書的資料先建到資料庫中
--
Tags:
普考
All Comments
By Tracy
at 2013-06-25T18:59
at 2013-06-25T18:59
By Anonymous
at 2013-06-28T19:39
at 2013-06-28T19:39
By Jacob
at 2013-07-02T21:34
at 2013-07-02T21:34
By Brianna
at 2013-07-07T19:17
at 2013-07-07T19:17
By Quintina
at 2013-07-12T10:37
at 2013-07-12T10:37
By Caitlin
at 2013-07-12T20:24
at 2013-07-12T20:24
By Todd Johnson
at 2013-07-17T02:16
at 2013-07-17T02:16
By Rae
at 2013-07-18T14:27
at 2013-07-18T14:27
By Queena
at 2013-07-22T05:59
at 2013-07-22T05:59
By Kyle
at 2013-07-22T07:41
at 2013-07-22T07:41
By Kyle
at 2013-07-24T19:42
at 2013-07-24T19:42
By Freda
at 2013-07-25T16:42
at 2013-07-25T16:42
By Jack
at 2013-07-27T20:29
at 2013-07-27T20:29
By Kama
at 2013-07-29T03:10
at 2013-07-29T03:10
By Lucy
at 2013-08-03T00:03
at 2013-08-03T00:03
By Wallis
at 2013-08-06T14:12
at 2013-08-06T14:12
By Ingrid
at 2013-08-09T13:53
at 2013-08-09T13:53
By Tracy
at 2013-08-13T13:20
at 2013-08-13T13:20
By Isla
at 2013-08-18T06:14
at 2013-08-18T06:14
By Aaliyah
at 2013-08-22T00:41
at 2013-08-22T00:41
Related Posts
102退除役三等行政法
By Faithe
at 2013-06-21T21:35
at 2013-06-21T21:35
今年普考開始有備取制,是如何分發呢?
By Sierra Rose
at 2013-06-21T11:57
at 2013-06-21T11:57
今年普考開始有備取制,是如何分發呢?
By Jessica
at 2013-06-21T00:07
at 2013-06-21T00:07
經濟學--選擇題
By Margaret
at 2013-06-20T18:31
at 2013-06-20T18:31
經濟學--選擇題
By Skylar Davis
at 2013-06-20T16:55
at 2013-06-20T16:55