Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Part A:
(10 points)
1) What does ACID stand for? Please articulate two of the ACID properties. ACID
Atomicity All or nothing. Requires that database modifications must follow an "all or nothing" rule. Each transaction is said to be atomic. If one part of the transaction fails, the entire transaction fails and the database state is left unchanged. Consistency- Property ensures that any transaction the database performs will take it from one consistent state to another. Isolation Database transaction should be isolated from all other transaction. Refers to the requirement that no transaction should be able to interfere with another transaction at all. In other words, it should not be possible that two transactions affecting the same rows run concurrently, as the outcome would be unpredicted and the system thus unreliable. Durability Once the data is safe, it is safe forever. This means that once a transaction has been committed, it will remain so. In other words, every committed transaction is protected against power loss/crash/errors and cannot be lost by the system and can thus be guaranteed to be completed.
The main idea of a relational model is that a database consists of a series of relations that can be manipulated using operations that return tables. An attribute is the characteristic or property of an entity in a relational model. It is a column that contains unique values for the specific table.
How would qualify for a street field in the Customer table? (5 points)
Customer.StreetName = the qualified name where Customer is the table in which the Street may be found.
Part B: (each question worth 5 point) (Henry Book Case): You need to use HenryBooks SQL Server database for the following questions. For answering the following questions, you need to provide the SQL commands as well as the query results for the questions.
1. List the author number and last name for every author.
SELECT AuthorNum, AuthorLast FROM Author
AuthorNum 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
AuthorLast Morrison Solotaroff Vintage Francis Straub King Pratt Chase Collins Heller Wills Hofstadter Lee Ambrose Rowling Salinger Heaney Camus Collins, Jr. Steinbeck Castelman Owen O'Rourke Kidder Schleining
2.
List the complete Branch table (all rows and all columns).
SELECT BranchNum,BranchName, BranchLocation, NumEmployees FROM Branch
BranchNum 1 2 3 4 3.
BranchName Henry Downtown Henry On The Hill Henry Brentwood Henry Eastshore
Publisher Name Berkley Publishing Course Technology 4. List the name of every branch that has at least 9 employees.
SELECT BranchName FROM Branch WHERE NumEmployees
> 8
BranchName Henry Downtown Henry Brentwood Henry Eastshore 5. List the book code, title, and price for each book with a price that is greater than $5 but less than $10.
SELECT BookCode, Title, Price FROM Book WHERE Price BETWEEN $5.00 AND $10.00
0808 2766 3743 5163 6328 6908 7559 8720 9882 9883 6.
The Edge Of Mice and Men Nine Stories Travels with Charley Band of Brothers Franny and Zooey The Fall When Rabbit Howls Slay Ride The Catcher in the Rye
6.99 6.95 5.99 7.95 9.60 5.99 8.00 6.29 6.99 5.99
List the book code and title of every book that has the type FIC and a price of less than $10.
SELECT BookCode, Title, Price, Type FROM Book WHERE Type='FIC' AND Price <$10
Title The Stranger Of Mice and Men Nine Stories Franny and Zooey The Fall The Catcher in the Rye
Customers that are part of a special program get a 15% discount off regular book prices. To determine the discounted prices, list the book code, title, and discounted price of every book. (Your calculated column should calculate 85% of the current price, which is 100% less a 15% discount.)
SELECT BookCode,Title,(Price * (100-15)/100) as DiscountPrice FROM Book
Title A Deepness in the Sky Magic Terror The Stranger Venice Second Wind The Edge Dreamcatcher: A Novel
1382 138X 2226 2281 2766 2908 3350 3743 3906 5163 5790 6128 6328 669X 6908 7405 7443 7559 8092 8720 9611 9627 9701 9882 9883 9931
Treasure Chests Beloved Harry Potter and the Prisoner of Azkaban Van Gogh and Gauguin Of Mice and Men Electric Light Group: Six People in Search of a Life Nine Stories The Soul of a New Machine Travels with Charley Catch-22 Jazz Band of Brothers A Guide to SQL Franny and Zooey East of Eden Harry Potter and the Goblet of Fire The Fall Godel, Escher, Bach When Rabbit Howls Black House Song of Solomon The Grapes of Wrath Slay Ride The Catcher in the Rye To Kill a Mockingbird
20.791000 11.007500 11.866000 17.850000 5.907500 11.900000 8.840000 5.091500 9.486000 6.757500 10.200000 11.007500 8.160000 32.257500 5.091500 11.007500 15.436000 6.800000 11.900000 5.346500 15.988500 11.900000 11.050000 5.941500 5.091500 15.300000
8.
List the book code, title, and publisher code for all books. Sort the results by title within publisher code.
SELECT BookCode,Title, PublisherCode FROM Book ORDER BY Title,PublisherCode
Title A Deepness in the Sky A Guide to SQL Band of Brothers Beloved Black House Catch-22 Dreamcatcher: A Novel
PublisherCode TB CT TO PL RH SC SC
7405 2908 6908 8092 3350 7443 2226 6128 0189 3743 2766 079X 9882 9627 9883 0808 7559 9701 3906 0200 9931 5163 1382 2281 0378 8720
East of Eden Electric Light Franny and Zooey Godel, Escher, Bach Group: Six People in Search of a Life Harry Potter and the Goblet of Fire Harry Potter and the Prisoner of Azkaban Jazz Magic Terror Nine Stories Of Mice and Men Second Wind Slay Ride Song of Solomon The Catcher in the Rye The Edge The Fall The Grapes of Wrath The Soul of a New Machine The Stranger To Kill a Mockingbird Travels with Charley Treasure Chests Van Gogh and Gauguin Venice When Rabbit Howls
PE FS LB BA BP ST ST PL FA LB PE PU JP PL LB JP VB PE BY VB HC PE TA WP SS JP