Sei sulla pagina 1di 7

ITEC 3500 Home Assignment 2 (80 points)

Date: August 30, 2011 Time Spent on Assignment: 6.5 Hours

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.

2) What is a relation? What are the characteristics of a relation? (10 points)


A two-dimensional table-style collection of data in which all entries are single-valued, each column has a distinct name, all the values in a column are values of the attribute that is identified by the column name, the order of columns is immaterial, each row is distinct, and the order of rows in immaterial. Also called a table. 1) The entries in a table are single-valued. 2) Each column has a distinct name. 3) All values in a column are values of the same attribute. 4) The order of columns is immaterial. 5) Each row is distinct. 6) The order of rows is immaterial.

3) How is the term attribute used in the relational model?

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.

What is a more common name for attribute?


Column

What are the other possible names for attributes? (5 points)


A) Field B) Column C) Property D) Characteristic

4) What does it mean to qualify a field name?


When you are qualifying a field name you are actually creating an unambiguous reference to a particular field by adding the table name of that field.

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.

5) When do you use an update query? (5 points)


You can use an update query to make changes to existing data. After you enter the word UPDATE you can indicate the table that you want to update or make changes to. For Example: If you decided to change the zip code of your customers address you could enter the command UPDATE Customer SET ZipCode = 31313

6) Describe the purpose of the SELECT command in relational algebra. (5 points)


The SELECT command in relational algebra retrieves specific rows from an already created table and saves it as a new table. This command includes the command WHERE followed by the condition. The rows that are retrieved are the ones where the condition is met. Then you type GIVING Answer and it creates a new table named Answer that contains the row that the customer zip is 31313. For Example: If you decided to find all of the customers with a zip code of 31313 from a table called Customer and you wanted the new table to be called Answer you could type SELECT Customer WHERE Zip=31313 GIVING Answer

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

BranchLocation NumEmployees 16 Riverview 1289 Bedford Brentwood Mall Eastshore Mall 10 6 15 9

List the name of every publisher located in Boston.


SELECT PublisherName FROM Publisher WHERE City = 'Boston'

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

BookCode 0180 0189 0200

Title A Deepness in the Sky Magic Terror The Stranger

Price 7.19 7.99 8.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

BookCode 0200 2766 3743 6908 7559 9883 7.

Title The Stranger Of Mice and Men Nine Stories Franny and Zooey The Fall The Catcher in the Rye

Price 8.00 6.95 5.99 5.99 8.00 5.99

Type FIC FIC FIC FIC FIC FIC

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

BookCode 0180 0189 0200 0378 079X 0808 1351

Title A Deepness in the Sky Magic Terror The Stranger Venice Second Wind The Edge Dreamcatcher: A Novel

DiscountPrice 6.111500 6.791500 6.800000 20.825000 21.207500 5.941500 16.660000

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

BookCode 0180 669X 6328 138X 9611 5790 1351

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

Potrebbero piacerti anche