+ 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.

Slides:



Advertisements
Similar presentations
TURKISH STATISTICAL INSTITUTE 1 /34 SQL FUNDEMANTALS (Muscat, Oman)
Advertisements

Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
(wrapping up from last week)
Database Design Chapter Five DATABASE CONCEPTS, 6th Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Structured Query Language Chapter Three Part 3 – Inserts, Updates, Deletes.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
Structured Query Language Part II Chapter Three CIS 218.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
1 Introduction to Web Application Introduction to Data Base.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Getting Started Chapter One DATABASE CONCEPTS, 7th Edition
Why Databases.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
Structured Query Language
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Concepts of Database Management, Fifth Edition
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
©Silberschatz, Korth and Sudarshan5.1Database System Concepts Chapter 5: Other Relational Languages Query-by-Example (QBE) Datalog.
Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Database Basics CPSC 4670/ Purpose of a Database The purpose of a database is to keep track of things Unlike a list or spreadsheet, a database.
© 2002 by Prentice Hall 1 Database Design David M. Kroenke Database Concepts 1e Chapter 5 5.
Database Design IST210 Class Lecture
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Concepts of Database Management Seventh Edition
Chapter 5 Database Processing. Neil uses software to query a database, but it has about 25 standard queries that don’t give him all he needs. He imports.
DATABASE TRANSACTION. Transaction It is a logical unit of work that must succeed or fail in its entirety. A transaction is an atomic operation which may.
Oracle DML Dr. Bernard Chen Ph.D. University of Central Arkansas.
Chapter 4 Database Processing Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall 4-1.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
STRUCTURED QUERY LANGUAGE SQL-II IST 210 Organization of Data IST210 1.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
+ Relational Model IST210 Class Lecture. + Premiere Products A new company that is going to sells random merchandise via sales representatives You have.
Structured Query Language
1 2 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 2 The Relational Model 1: Introduction, QBE, and Relational Algebra.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
+ Complex SQL Week 9. + Today’s Objectives TOP GROUP BY JOIN Inner vs. Outer Right vs. Left.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Structured Query Language SQL-II IST 210 Organization of Data IST2101.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Structured Query Language
The Relational Model Chapter Two DATABASE CONCEPTS, 3rd Edition
David M. Kroenke and David J
Structured Query Language
Getting Started Chapter One DATABASE CONCEPTS, 5th Edition
Presentation transcript:

+ 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 want to change. Be as selective as possible! Need to know the correct format and syntax for statements. ( ), ‘’ ; Select From Where Order by

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

+ 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

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

+ Midterm Review

+ 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

+ 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

+ 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

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

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

+ 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

+ 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

+ 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, ) B. STUDENT(StudentID, FirstName, LastName, ) C. Student(StudentID, FirstName, LastName, ) D. STUDENT(StudentID, FirstName, LastName, )

+ 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)

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

+ 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

+ 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

+ 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,

+ 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)

+ 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)

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

+ 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

+ SQL Review

+ 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) );

+ 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

+ 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

+ Updating Data UPDATE EMPLOYEE SET Phone = ' ' 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

+ 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

+ 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

+ 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

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

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

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

+ 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;

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

+ 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;

+ 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%');

+ 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%';

+ 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

+ 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

+ 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