Paul Jacobs The iSchool University of Maryland Thursday, Oct. 5, 2017

Slides:



Advertisements
Similar presentations
Database Fundamentals
Advertisements

Relational Database Systems Higher Information Systems Advanced Implementation in MySQL/PHP.
Data Modelling. EAR model This modelling language allows a very small vocabulary: Just as English has nouns, verbs, adjectives, pronouns.., EAR models.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
SQL Basics+ Brandon Checketts. Why SQL? Structured Query Language Structured Query Language Frees programmers from dealing with specifics of data persistence.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
Database Technical Session By: Prof. Adarsh Patel.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
1 Introduction to Database Systems. 2 Database and Database System / A database is a shared collection of logically related data designed to meet the.
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
HSCI 709 SQL Data Definition Language. SQL Standard SQL-92 was developed by the INCITS Technical Committee H2 on Databases. SQL-92 was designed to be.
Introduction to MySQL Lab no. 10 Advance Database Management System.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
Database Systems Lecture 1. In this Lecture Course Information Databases and Database Systems Some History The Relational Model.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
Introduction to Database Programming with Python Gary Stewart
Fundamental of Database Systems
SELECT, IMPLEMENT & USE TODAY’S ADVANCED BUSINESS SYSTEMS
CS 325 Spring ‘09 Chapter 1 Goals:
Introduction to DBMS Purpose of Database Systems View of Data
Web Systems & Technologies
CS 3630 Database Design and Implementation
CS320 Web and Internet Programming SQL and MySQL
Understanding SQL Statements
Chapter 1: Introduction
Database System Concepts and Architecture
Information Systems Today: Managing in the Digital World
INFM 603: Session 5 Introduction to Databases and Database Design
Chapter 1: Introduction
Data Definition and Data Types
Chapter 4 Relational Databases
CS1222 Using Relational Databases and SQL
Paul Jacobs The iSchool University of Maryland Thursday, Oct. 6, 2016
CS 174: Server-Side Web Programming February 12 Class Meeting
DATABASE MANAGEMENT SYSTEM
Chapter 2 Database Environment.
PHPMyAdmin.
Teaching slides Chapter 8.
SQL OVERVIEW DEFINING A SCHEMA
Structured Query Language
Data Model.
Database Systems Instructor Name: Lecture-3.
Introduction to DBMS Purpose of Database Systems View of Data
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Chapter 1: Introduction
CS3220 Web and Internet Programming SQL and MySQL
Database Management Systems
CS4433 Database Systems Project.
Chapter 1: Introduction
Chapter 1: Introduction
Chapter 1: Introduction
Summary Data Modeling SDLC What is Data Modeling
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Chapter 1: Introduction
Presentation transcript:

Paul Jacobs The iSchool University of Maryland Thursday, Oct. 5, 2017 INFM 603: Session 6 Database Implementation Using PHP and MySQL Paul Jacobs The iSchool University of Maryland Thursday, Oct. 5, 2017 This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States See http://creativecommons.org/licenses/by-nc-sa/3.0/us/ for details

Today’s Topics Review of Database Fundamentals How to Build/Query/Update Online Relational Databases Hands-on Practice

Database Fundamentals - Review What is a database? A computer mechanism for online persistent storage, organization and access to information (a technology) Why do we need them? To maintain information in a consistent, convenient, reliable way that enables applications (a tier or architectural component) How do we use them? Building a (usually) relational model called a schema that organizes data in tables and supports needed functionality; writing code for interfaces (implementation) Database Fundamentals Implementation Hands-on Practice

Database Implementation – Types of Database Problems Design and Document a Database Figure out what data has to be in there How is the data structured? What are the types of data (e.g., names, dates, strings, etc.)? Build the schema Document it (so that you or someone else can implement it) Build a Database Create the database (tables), users, security, etc. (usually done by designer and/or DBA – administrator using various interfaces and/or ODBC/SQL) Validate that it works Populate the database (enter records) Database Fundamentals Implementation Hands-on Practice

Database Implementation –Database Problems (cont’d) Program a Database Develop interfaces for end users (e.g. to search, access information from databases – e.g., Testudo) Develop interfaces for other systems (e.g., to place orders, perform updates, etc. – e.g., Canvas, Amazon) Query a Database Access data (records) already in the database Can be done using all kinds of interfaces, or by programs (often using ODBC/SQL) Very often done by users who are not allowed to update or change the data themselves Database Fundamentals Implementation Hands-on Practice

Documenting a Database Usually specifies the schema, especially the tables (or object classes in an object-oriented format), but can be at various levels and description and abstraction Can be used to communicate among different parts of a technical project team (e.g., user groups, programmers, database designers, etc.) Can use any number of documentation methods E-R diagrams Class diagrams with annotations Sketches and drawings of all sorts (such as what we used last time) Actual database output from some stage of implementation Best done relatively early in project because of need to build and test code to interface with the database Database Fundamentals Implementation Hands-on Practice

Database Implementation - Introduction to SQL

What is SQL (Structured Query Language)? The “interlingua” of relational databases (e.g., Oracle, SQLServer, MySQL, Postgres, DB2, etc.) An international standard (ISO 9075) A common method of building and querying databases A common method of building database interfaces (e.g., using ASP, JSP, PHP) A common method of building connectors from applications to databases (e.g., using XML, SOAP and ODBC/JDBC) Database Fundamentals Implementation Hands-on Practice

Basic SQL functions (on records) SELECT – get records from a database that meet certain criteria INSERT – add records to a database UPDATE DELETE Database Fundamentals Implementation Hands-on Practice

Basic SQL functions - SELECT SELECT CustomerAddress FROM Customers WHERE CustomerName = ‘Will E. Coyote’; SELECT * FROM SalesOrders LIMIT 0,30; Database Fundamentals Implementation Hands-on Practice

PHPMyAdmin Output - SELECT Database Fundamentals Implementation Hands-on Practice

SELECT Using JOIN SELECT SalesOrders.SalesOrderNo, Customers.CustomerName FROM SalesOrders JOIN Customers ON (SalesOrders.CustomerNo = Customers.CustomerNo) ; Database Fundamentals Implementation Hands-on Practice

PHPMyAdmin Output - Join Database Fundamentals Implementation Hands-on Practice

Basic SQL functions - INSERT INSERT INTO `inclassdemo`.`OrderItems` ( `SalesOrderNo` , `ItemNo` , `ItemQuantity` , `ItemUnitPrice` ) VALUES ( '1', '1', '12', '10.50'); Database Fundamentals Implementation Hands-on Practice

Basic SQL functions - UPDATE UPDATE `inclassdemo`.`SalesOrders` SET `CustomerNo` = '5', `ClerkNo` = '2' WHERE `SalesOrders`.`SalesOrderNo` =1 LIMIT 1 ; Database Fundamentals Implementation Hands-on Practice

Basic SQL functions - DELETE DELETE FROM Customers WHERE CustomerName = 'Peter Piper'; Database Fundamentals Implementation Hands-on Practice

Basic SQL functions (on tables) CREATE – make a new table DROP – delete a table ALTER – change (e.g., fields) of a table Database Fundamentals Implementation Hands-on Practice

Basic SQL functions - CREATE CREATE TABLE `SalesOrders` ( `SalesOrderNo` INT( 6 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `Date` DATE NOT NULL , `CustomerNo` INT NOT NULL , `ClerkNo` INT NOT NULL , `Total` FLOAT( 9, 2 ) NOT NULL ) [in MySQL requires separate constraint PRIMARY KEY (SalesOrderNo)] Database Fundamentals Implementation Hands-on Practice

Basic SQL functions – DROP AND ALTER DROP TABLE Pets; ALTER TABLE SalesOrders ADD Season VARCHAR (10); Database Fundamentals Implementation Hands-on Practice

Building the Sample Database Using MySQL

Example Database (Final Tables) Table: SalesOrders SalesOrderNo Date CustomerNo ClerkNo Total Table: OrderItems ItemNo ItemQuantity ItemUnitPrice Table: InventoryItems ItemNo ItemDescription Table: Customers CustomerNo CustomerName CustomerAddress Table: Clerks ClerkNo ClerkName Database Fundamentals Implementation Hands-on Practice

Building the Sample With PHPMyadmin – Create Tables Database Fundamentals Implementation Hands-on Practice

Building the Sample With PHPMyadmin – Add Data Database Fundamentals Implementation Hands-on Practice

Building the Sample With PHPMyadmin – Add Data (SQL) Database Fundamentals Implementation Hands-on Practice

Building the Sample With PHPMyadmin – Build Queries Database Fundamentals Implementation Hands-on Practice

Build and populate the sample database Hands On Practice Build and populate the sample database

SQL is Quite Powerful Data types – Most common are INT (Integer), VARCHAR (Variable length string), and DATE, but there are many other related types, e.g. TIMESTAMP, BLOB (binary large object), FLOAT (floating point) Functions – There are functions for almost any data type, e.g. – Date conversion and formatting, such as DATE_FORMAT(Date, ‘%b . %m, %Y) TIMESTAMPDIFF(YEAR, BirthDate,CURDATE()) All kinds of arithmetic, like SQRT() and POW() Numerous tools and tricks for manipulating, sorting, comparing, etc. Database Fundamentals Implementation Hands-on Practice

Example: Typical Contact DB Database Fundamentals Implementation Hands-on Practice

Example: Age Query Database Fundamentals Implementation Hands-on Practice

Example: Birthday Query Database Fundamentals Implementation Hands-on Practice

Database Implementation - Recap Reviewed the role of databases in [web] applications Introduced SQL as the “interlingua” of relational databases Presented and tried out one type of database server using PHPMyAdmin/MySQL Next up: Integrating with web pages via PHP and other advanced methods, tying things together Database Fundamentals Implementation Hands-on Practice