Presentation is loading. Please wait.

Presentation is loading. Please wait.

+ Midterm Review. + Notes from the Midterm When updating, deleting records Make sure you have a WHERE statement that only will give you the row(s) you.

Similar presentations


Presentation on theme: "+ Midterm Review. + Notes from the Midterm When updating, deleting records Make sure you have a WHERE statement that only will give you the row(s) you."— Presentation transcript:

1 + Midterm Review

2 + Notes from the Midterm When updating, deleting records Make sure you have a WHERE statement that only will give you the row(s) you want to change. Be as selective as possible! Need to know the correct format and syntax for statements. ( ), ‘’ ; Select From Where Order by

3 + Midterm Statistics _54_ students took the Average = _85.6_/100 Max = _99_/100 Min = _57_/100 No curve applied.

4 + Looking Forward – The Next 7 Weeks Week 9 – Complex SQL Week 10 – SQL - Once More With Feeling Week 11 – Connecting to the web Week 12 – XML / XSLT Week 13 – Big Data / Network Analysis Week 14 – Project work and help Week 15 – Review / Wrap up Final – Wed, Dec. 16, 2:30-4:20, 205 IST Building

5 + Final Exam Wednesday, Dec 16 2:30 – 4:20 205 IST Building

6 + Midterm Review

7 + 1.) ACID Properties refer to: A. Accessibility, Concurrency, Inclusion, Determinants B. Atomicity, Concurrency, Isolation, Determinants C. Atomicity, Consistency, Isolation, Durability D. Architecture, Consistency, Inclusion, Durability

8 + 2.) The Three parts of CAP Theorem (Brewer’s Theorem) are: A. Construction, Availability, Presentation B. Construction, Availability, Partition Tolerance C. Consistency, Accuracy, Presentation D. Consistency, Availability, Partition Tolerance

9 + 3.) We might classify a data type as “Big Data” if it: A. Had a dataset consisting of an enormous number of records B. Data was generated at an extremely fast rate C. The size, number, or speed of data made analysis difficult with traditional relational database methods D. All of the above

10 + 4.) DBMS stands for: A. Data Block Memory Standard B. Database Management System C. Determinant Bit Management System D. Database Memory Standard

11 + 5.) SQL stands for: A. Structured Query Language B. Semantic Query Language C. Semantic Quotient Library D. Structured Quotient Library

12 + 6.) NoSQL A. Is a collection of databases that operate differently than relational databases. B. Is meant to replace relational databases in the next 10 years. C. Focus on scalability and availability D. Both A and C

13 + 7.) Which of the following would be considered problems with lists: A. The same information can be in multiple places B. You have to type all of the entries C. Deleting an entry from the list could cause important data to be lost. D. Both A and C

14 + 8.) STUDENT If you were told that the above representation had a Primary Key declared for “StudentID”, then the proper text representation of this as a relation would be: A. Student(StudentID, FirstName, LastName, Email) B. STUDENT(StudentID, FirstName, LastName, Email) C. Student(StudentID, FirstName, LastName, Email) D. STUDENT(StudentID, FirstName, LastName, Email)

15 + 9.) CLASS(ClassID, Name, Description, Credits, College, InstructorID) For this Relation: A. The Primary Key is “ClassID” and a Foreign Key is “Instructor”. B. The Primary Key is “InstructorID” and a Foreign Key is “ClassID”. C. A Compound Key is (ClassID, InstructorID) D. A Surrogate ID is (Name, Description, Credits)

16 + 10.) What is NOT a component of a database system? A. DBMS B. Database Application C. Users D. Computer

17 + 11.) A(n) ___________________is a person, place, object, event, or idea for which you want to store and process data. A. Attribute B. Entity C. Tuple D. Column

18 + 12.) Transformation of complex user views and data to a set of smaller, stable, and easily maintainable data structures A. Denormalization B. Data Structures C. Normalization D. Query

19 + 1.) Write an SQL statement to make the STUDENT table. (6 points) 2.) Write the SQL statement to add the following student into the student table. (5 points) Robert Smith, 202 Main Street, State College, PA 16801, 814- 555-1234

20 + 3.) Robert did not like his apartment and has now moved next door, his new address is 206 Main Street. Write the SQL statement to make this change in the database. (5 points) 4.) Write the SQL statement that will provide a list of all the student information (5 points)

21 + 5.) Write the SQL statement that will provide a list of all the students (first and last names) in alphabetical order by last name that are enrolled in IST210 (hint IST210 is a ClassID) (8 points) 6.) Robert has gone and got himself kicked out of school, write the SQL statement to remove him from the Database. (5 points)

22 + 1.) What are the entities and their attributes for the figure below? (8 points)

23 + 2.) Given the following relations draw a CrowsFoot relational diagram. Do not worry about including all attributes for the entities. If you make any assumptions about relationships please state your assumption and rationale. (10 points) The Entities required are: Suppliers, Products, Orders, Customers The Entities are related as follows: A Customer can have one or many Orders An Order can contain one or many Products A Product can be associated with one or many Orders A Supplier can supply one or many Products

24 + SQL Review

25 + Create Table CREATE TABLE EMP_SKILL( EmpID Integer NOT NULL, SkillID Integer NOT NULL, SkillLevel IntegerNULL, CONSTRAINT EmpSkill_PK PRIMARY KEY (EmpID, SkillID), CONSTRAINT Emp_FKFOREIGN KEY(EmpID) REFERENCES EMPLOYEE(EmpID), CONSTRAINT Skill_FK FOREIGN KEY(SkillID) REFERENCES SKILL(SkillID) );

26 + Alter Table ALTER TABLE EMPLOYEE ADD CONSTRAINT Emp_PK PRIMARY KEY(EmpID); KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

27 + Inserting Data INSERT INTO EMPLOYEE VALUES(91, 'Smither', 12); INSERT INTO EMPLOYEE (EmpID, SalaryCode) VALUES (62, 11); KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

28 + Updating Data UPDATE EMPLOYEE SET Phone = '791-555-1234' WHERE EmpID = 29; UPDATE EMPLOYEE SET DeptID = 44 WHERE EmpName LIKE 'Kr%'; KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

29 + Deleting Data DELETE FROM EMPLOYEE WHERE EmpID = 29; DELETE FROM EMPLOYEE WHERE EmpName LIKE ' Kr% ' ; KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

30 + Match Criteria Equals “=” Not Equals “<>” Greater than “>” Less than “<” Greater than or Equal to “>=” Less than or Equal to “<=” Multiple Values “In” Variable Values “Like” KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

31 + Match Operators AND Representing an intersection of the data sets OR Representing a union of the data sets KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

32 + Class Activity Add the person next to you as a new Customer to the Sweeney Database

33 + Queries SELECT * FROM EMPLOYEE; SELECT EmpName FROM EMPLOYEE WHERE EmpID = 2010001; SELECT DISTINCT DeptID FROM EMPLOYEE; KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

34 + Queries SELECT EmpName FROM EMPLOYEE WHERE DeptID < 7 OR DeptID > 12; SELECT EmpName FROM EMPLOYEE WHERE DeptID = 9 AND SalaryCode <= 23;

35 + Queries SELECT EmpName FROM EMPLOYEE WHERE DeptID IN (4, 8, 9); SELECT EmpName FROM EMPLOYEE WHERE DeptID NOT IN (4, 8, 9); SELECT EmpName FROM EMPLOYEE WHERE SalaryCode BETWEEN 10 AND 45;

36 + Queries SELECT EmpID FROM EMPLOYEE WHERE EmpName LIKE 'Kr%'; SELECT EmpID FROM EMPLOYEE WHERE Phone LIKE '616-___-____';

37 + Queries SELECT * FROM EMPLOYEE WHERE EmpName LIKE 'Kr%' ORDER BY EmpName; SELECT COUNT(DeptID) FROM EMPLOYEE; SELECT MIN(Hours) AS MinimumHours, MAX(Hours) AS MaximumHours, AVG(Hours) AS AverageHours FROM PROJECT WHERE ProjID > 7;

38 + Queries SELECT DeptID, COUNT(*) AS NumOfEmployees FROM EMPLOYEE GROUP BY DeptID HAVING COUNT(*) > 3; SELECT EmpName FROM EMPLOYEE WHERE DeptID in(SELECT DeptID FROM DEPARTMENT WHERE DeptName LIKE 'Account%');

39 + Queries SELECT EmpName FROM EMPLOYEE AS E, DEPARTMENT AS D WHERE E.DeptID = D.DeptID AND D.DeptName LIKE 'Account%'; SELECT EmpName FROM EMPLOYEE AS E JOIN DEPARTMENT AS D ON E.DeptID = D.DeptID WHERE D.DeptName LIKE 'Account%';

40 + SQL for Data Retrieval: LEFT OUTER JOIN Example The OUTER JOIN syntax can be used to obtain data that exists in one table without matching data in the other table. SELECT EmpName FROM EMPLOYEE AS E LEFT JOIN DEPARTMENT AS D ON E.DeptID = D.DeptID WHERE D.DeptName LIKE 'Account%'; KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

41 + SQL for Data Retrieval: RIGHT OUTER JOIN Example The unmatched data displayed can be from either table, depending on whether RIGHT JOIN or LEFT JOIN is used. SELECT EmpName FROM EMPLOYEE AS E RIGHT JOIN DEPARTMENT AS D ON E.DeptID = D.DeptID WHERE D.DeptName LIKE 'Account%'; KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall

42 + TOP Clause specify how many rows to return. This can be useful on very large tables when there are thousands of records. Returning thousands of records can impact on performance, and if you are working with a production database, this could have an adverse impact on the users. SELECT TOP (3) EmpName FROM EMPLOYEE


Download ppt "+ Midterm Review. + Notes from the Midterm When updating, deleting records Make sure you have a WHERE statement that only will give you the row(s) you."

Similar presentations


Ads by Google