CSE4701 Introduction to Databases Prof. Steven A. Demurjian Computer Science & Engineering Department The University of Connecticut 371 Fairfield Way, Box U-255 Storrs, CT 06269-3255 steve@engr.uconn.edu http://www.engr.uconn.edu/~steve (860) 486–4818 (Office) (860) 486-3719 (CSE Office)
Course Goals Provide a Practical Introduction to Database Models, Theory, and Systems Focus on Both Theory and Practice Theory Demonstrates Strong Mathematical Basis of Databases (Relational Model and Concurrency Control) Practice Provides Experimental Framework for Illustrating Theory (Actual Database Systems and their Usage) Exposure to Research Problems and Real-World Experiences
Course Philosophy Introduction to Fundamental Database Concepts Promotion of Knowledge-Acquisition, Self-Learning, and Independence Rapid Evolution of Computing Always Must Keep Skills Up-to-Date “Learn how to Learn” Relevance of Database Concepts in Computing Software Engineering Object-Oriented Computing Operating Systems and Networks Almost Every Computer Science Area Practical Exposure to SQL, JDBC, and DB Platform (MySQL and Workbench)
Textbooks and Class Materials UConn Bookstore has One Required Text … Fundamentals of Database Systems, Elmasri and Navathe, Addison-Wesley 6th (2009) edition CSE4701 Web Site at … www.engr.uconn.edu/~steve/Cse4701/cse4701.html All Course Notes, Project Materials, Web Site Links, Available On-Line Other Class Materials Various other Web Sites
Syllabus: Weekly Topic Coverage Weeks Topic Chapters FOCUS ON CHAPTER TOPIC - NUMBERS FOR 6th/5th eds. 1 Introduction/Overview Ch 1,2 1.5 Relational Model Ch 3&6 6e, 7 5e 1 Basic & Advanced SQL Ch 4&5 6e, 8 5e 1.5 Conceptual DB/ER Model Ch 7&8 6e, 3&4 5e 1 ER-Relational Transl. Ch 9 6e, 5 6e 1.5 DB Design, Normal Forms Ch 15&16 6e, 14 5e 1 XML & SQL Prog/PHP Ch 12&13&14 6e 1 Design/Storage/Index Ch 17&18 6e, 13&14 5e 1 System Catalog/Query Op Ch 19 6e, 17&18 5e 1 Trans Proc/Conc. Cont. Ch 21&22 6e, 19&20 5e 1 Security & Recovery Ch 22&23 6e, 21&22 5e 1 DBMS/Web/Mining Ch 26/28/29 6e, 24/26/27 5e 1 One Semester Exams + Final Exam
Course Projects and Exams Projects: Individual &/or Team (30-50% of Grade) In Process of Being Defined We’ll Review … Exams (40-50% of Grade) Likely Two Exams and Final Open Book and Open Notes Home works (0-20%) Throughout the Semester - In Class also If no credit, Up to 2 Bonus Pts. Per Handed in Assignment Sp15/Fa15 – 40%P, 50%E, 10%H Must Pass Both Projects And Exams to PASS!!! Note: All Subject to Change – Use Breakdown that Most Benefits Students
Cheating/Collaboration Not Tolerated in Any Form!!! Severe Penalties are Likely!!! See University of Connecticut Student Conduct Code All Homeworks/Some Project Represent Individual Effort! Remaining Projects Represent Team Effort Cooperative Problem Solving and Sharing Code is NOT Permitted and Will Likely Lead to Fs! Electronic Information is More Accessible! Use Protection Capabilities on your Account to Protect your Files!
Lateness Policies/Exams Late Assignments (Projects) will Not be Accepted Except with Prior Permission or Emergencies Prior Permission: Contact the Instructor Three Days Before the Due Date Emergencies: Illness, Death in the Family, etc. Contact S. Demurjian at ITE265, x6-4818, by steve@engr.uconn.edu, or via the CSE Office, ITE250, x6-3719 A Late Assignment is Recorded as a Zero Grade Assignment Due Date Means Start of Class!!! Makeup on Absent Exam at Instructor’s Discretion
Class Attendance and Computing Attendance in Class is … Responsibility of each Student May Result in Missing Hint/Clarification/Error on Class Project Change in Due Date or Exam Date I Won’t Guarantee that All Information Makes it to Web! Computing for Class is … Predominately PCs - ITE Concourse Level or Engineering Learning Center (ITE 1st floor) Take Files with You! Your Responsibility to Protect Your Files
Remainder of Today’s Material What is a Database? Motivation, Defining, Tables, Querying Main Software for the Course MySQL and MySQL Workbench Other Technologies XAMPP and MyphpAdmin A Useful Windows Utility Homework 0 Introducing the Semester Project
What is a Database? Database (DB) is a Structured Collection of Data about the Entities that Exist in an Enterprise and that are Used (Shared) by Applications of an Enterprise The Structure of the Database is Dependent Upon the Data Model that is Used - Understanding the Terms: Database (DB) Database System (DBS) Database Management Systems (DBMS) What can be a Database? Address Book, Contact List, Calendar, Bookmarks, Flat File Against Which a Program is Executed, Real-Time Data Sensor Feed into Embedded Program, Set of Word or Excel Documents, Fitness Data from App or Device, Recipes, etc.
What Does a Database Contain? Conceptually – One View Consider Excel Spreadsheet with Multiple Tabs Tabs: Employee, Department, Projects, Each Tab has Columns that Each have Own Types Each Tab has Data for All Columns/Multiple Rows Data is Static, Human Readable/Updateable
Excel Spreadsheet Example
What Does a Database Contain? Conceptually – Another View Consider a set of Java Classes Employee, Manager ISA Employee, Department, Projects, etc. Each Class has Single Instance Need to Use Collection in Java for Set of Instances class Employee { private String Name, SSN, Address; private Date BirthDate; private double Salary; private integer DeptNum; public Empolyee() { ... }; };
What are Problems with each? Both Cases: Data is Not Stored in a Permanent Repository Data Not easily Sharable/Modified by Multiple Users Simultaneously Data Consistency Constraints Not Enforceable DeptNum in Employee/Project vs. Number in Department Same Issue across Classes Need Way to Persistently store Data Accessible by Multiple Users
Defining a Database Table CREATE TABLE EMPLOYEE ( FNAME VARCHAR(15) NOT NULL , MINIT CHAR , LNAME VARCHAR(15) NOT NULL , SSN CHAR(9) NOT NULL , BDATE DATE ADDRESS VARCHAR(30) , SEX CHAR , SALARY DECIMAL(10,2) , SUPERSSN CHAR(9) , DNO INT NOT NULL , PRIMARY KEY (SSN) , FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN) , FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNUMBER) ) ;
A Schema Contains Multiple Tables
…filled with Rows of Tuples/Instances Which Represent Tuples/Instances of Each Relation A S C null W B 1 4 5
…filled with Rows of Tuples/Instances
SQL Searches the Tables Retrieve the Birthdate and Address of the Employee whose Name is 'John B. Smith'. SELECT BDATE, ADDRESS FROM EMPLOYEE WHERE FNAME='John' AND MINIT='B’ AND LNAME='Smith’ Which Row(s) are Selected? B S C null W
Main Software for Class MySQL and MySQL Workbench
Loading a Database Schema Select File, Open SQL Script, and browse to the directory to select demo-1.11.0.sql and from the window below, select, the Open option
Loading a Database Schema
The Database Tables
To Load a Database – back to this Tab Click on Localhost MySQL and MySQL Workbench
Takes five or more Minutes Result is Following Screen Select Run SQL Script choose demo-1.12.0.sql Note: Lots of Data, Takes five or more Minutes
Takes five or more Minutes Result is Following Screen Select Run SQL Script choose demo-1.11.0.sql Note: Lots of Data, Takes five or more Minutes
Screen that Appears while Loading .sql
Resulting Screen to Query Database
Querying the Database SELECT * FROM OpenMRS.Person;
Result of Query
Query Results Window
Export to csv
Extended Entity Relation Diagram
SELECT * FROM OpenMRS.Person;
SELECT * FROM OPENMRS.person_name;
Person & Person_name Tables link person_id
Other Technologies - XAMPP XAMPP includes: Apache, PHP, MySQL, and other goodies. No need to download and install them separately, XAMPP does it all. Download: https://www.apachefriends.org/download.html FAQs (Includes instructions on how to install it and set it up): Windows FAQs: https://www.apachefriends.org/faq_windows.html OSX FAQs: https://www.apachefriends.org/faq_osx.html Linux FAQs: https://www.apachefriends.org/faq_linux.html
The XAMPP Control Panel
Other Use Technologies -phpMyAdmin
Another Useful Capability Suppose Install MySQL + Workbench Then Install XAMPP Which Also Installs MySQL May End up with Multiple Instances of MySQL On Windows/Control Panel/Admin Tools/Services
On Windows/Control Panel/Admin Tools/Services Stop Start Pause Service
Homework 0 Install MySQL Homework 0 http://www.engr.uconn.edu/~steve/Cse4701/MySQLinstall.docx Homework 0 http://www.engr.uconn.edu/~steve/Cse4701/cse4701hw0Instructions.docx Install and Play with Chinook and Northwind DBs Also Explore XAMPP and MyphpAdmin
Chinook Loaded with Query on Employee Arrow shows save to a csv file
Query Results in Excel
Project Requirements Team Project - Discussion Between Teams Allowed if you are Helping with DB Configuration, Programming Question, etc., NOT Joint Design/Development! Will either Be Teams of 3 Implementation Languages/Platform DB/Server side: MySQL Workbench, php UI Aptana Studio 3 Mobile UI App Framework http://noeticforce.com/best-hybrid-mobile-app-ui-frameworks-html5-js-css Should work on Chrome
Project Focus Design, Extend, Develop, and Test a UI/ Information System for Customers and Employees of Either: NorthwindExtended Database Sample – Database of Employees, Customers, Suppliers, etc. https://code.google.com/p/northwindextended/ Phases I and II posted … may be updated before assigned
Northwind
Clients and Software Architecture Web Client Connect and Interact with MySQL REST php API MySQL Web Client Front half contains API (Java calls) that hide DB interactions from Client Back half is the implementation of the classes that contains code to open the database connection, perform a query, collect results, etc.