Creating Databases for Web applications Making a table of table information. Reprise on database design. SQL. Classwork/Homework: Projects! Postings.

Slides:



Advertisements
Similar presentations
How to Create a Local Collection
Advertisements

Relational Database Systems Higher Information Systems Advanced Implementation in MySQL/PHP.
Keys, Referential Integrity and PHP One to Many on the Web.
ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Maintaining Referential Integrity Pertemuan 2 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Introduction to Structured Query Language (SQL)
View Sen Zhang. Views are very common in business systems users view of data is simplified a form of security - user sees only the data he/she needs to.
Concepts of Database Management Sixth Edition
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
Creating Database Tables CS 320. Review: Levels of data models 1. Conceptual: describes WHAT data the system contains 2. Logical: describes HOW the database.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
CSC 2720 Building Web Applications Database and SQL.
Information systems and databases Database information systems Read the textbook: Chapter 2: Information systems and databases FOR MORE INFO...
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Creating Databases SELECT. UPDATE. Demonstrate projects. Classwork / Homework: Prepare to choose teams & projects.
Creating databases for web applications
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
Creating databases for web applications Walk before run? Songs with features example. Retrieve information from database. Recordsets. Arrays. Loops. Homework:
Creating Databases for Web Applications SQL Select extras Listing [names of] tables generalized display of recordset simple password handling php and other.
Creating databases for web applications SQL. Systems design. ER diagrams. Data flow diagrams. Storyboards. Homework: Plan database and applications for.
Creating Databases for Web applications Making a table of SQL queries. PHP and other DBMSs. Rights. Left Join, etc. Homework: Make posting on Open Source.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
PHP meets MySQL.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
Creating Databases More SQL. Design. Original Project Assignment Homework: Post proposal. Continue with planning.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 2720 Building Web Applications Database and SQL.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
10/17/2012ISC471/HCI571 Isabelle Bichindaritz 1 Technologies Databases.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Using Special Operators (LIKE and IN)
Database Systems Microsoft Access Practical #3 Queries Nos 215.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
Creating PHPs to Insert, Update, and Delete Data CS 320.
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
Creating Databases Local storage. join & split Classwork: show 1 table application. Share designs for oscars application. Adaptive select. Homework: [Catch.
Creating Databases for web applications [Complete presentations] More SQL Class time: discuss final projects. Do posting if you have not done it.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Creating databases for web applications Library. New example: student database. Homework: Complete class example. Catch up on source postings. Do creation.
1 CSE 2337 Introduction to Data Management Access Book – Ch 1.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
06 | Modifying Data in SQL Server Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
# 1# 1 QueriesQueries How do we ask questions of the data? What is SELECT? What is FROM? What is WHERE? What is a calculated field? Spring 2010 CS105.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
 CONACT UC:  Magnific training   
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
DAY 20: ACCESS CHAPTERS 5, 6, 7 Larry Reaves October 28,
Confirm teams. Review of diagrams. SELECT problems.
SQL Query Getting to the data ……..
Relational Model.
Creating Databases More SQL. Design. Original Project Assignment
Insert, Update, Delete Manipulating Data.
Relational Database Design
Presentation transcript:

Creating Databases for Web applications Making a table of table information. Reprise on database design. SQL. Classwork/Homework: Projects! Postings.

<?php require("opendbo.php"); $query="show tables"; $rs=mysqli_query($link, $query); ?> Table names <?php $i = 0; while ($row=mysqli_fetch_array($rs)){ print(" "); $tablenames[$i] = $row[0]; $i++; print($row[0]); print(" "); } print(" ");

for ($j=0;$j<$i;$j++) { $query = "describe ".$tablenames[$j]; print (" ". $tablenames[$j]. " table \n "); print (" Field Type Null Key \n "); $rt=mysqli_query($link,$query); while ($fi=mysqli_fetch_array($rt)) { print (" ". $fi['Field']. " \n "); print (" ".$fi['Type']. " \n "); print (" ".$fi['Null']. " \n "); print (" ".$fi['Key']. " \n "); print (" "); } print (" "); } ?>

my query on table info eyer/showtableinfo.php

Challenge What if you have a large set of queries for the user –one of my earliest assignments at a hospital: the abominable abdominal report –?

Table of queries If you have a large set of fixed SQL queries, you may make a new table: iddescriptiontext 1final diagnosis when presenting signs of appendicitis Select final.diagnosis from final, initial where initial.temp > 100 AND initial.pain = 'left' AND final.caseno = initial.caseno 2initial potential ulcer cases Select * from initial where initial.pain = 'sharp' AND initial.temp < 100 ….

Present to user Pick selection: description final diagnosis when presenting signs of appendicitis initial potential ulcer cases Don't show the user the messy SQL

Produce responses Make the query the SQL corresponding to the user's choice. Display recordset in a table –Now, need generalized code that creates headings for tables and extracts names of fields 'on the fly' based on information in recordset. php: –mysqli_fetch_field –mysqli_fetch_array

<?php require("opendbo.php"); $query="Select * from customers"; $result=mysqli_query($link, $query); $fieldnames= Array(); print (" "); $nf = mysqli_num_fields($result); for ($i=0; $i<$nf;$i++) { $fieldobj= mysqli_fetch_field($result); $fieldnames[$i]=$fieldobj->name; print (" ".$fieldnames[$i]." "); } print (" \n"); while ($row=mysqli_fetch_array($result)) { print (" "); for ($i=0; $i<$nf; $i++) { print (" ".$row[$fieldnames[$i]]." "); } print(" "); } mysqli_close($link); ?> first for loop to set up headers Second for loop, in while loop, to extract field data.

Note meyer/showCurrentCustomers.phphttp://socialsoftware.purchase.edu/jeanine. meyer/showCurrentCustomers.php If you do [ever] show field names to your customers/clients/players/…, –you need to make them longer/better/etc. –Make sure database doesn't have blanks, etc.

MySQL Rights Possible to limit rights to specific users. –specific table or whole database –SELECT, INSERT, DELETE, UPDATE, DROP, CREATE, ALTER NOTE: I don't know if your rights include right to use GRANT! Limiting rights is to prevent unintentional errors as much as / more than not trusting certain people. Your php code is main line of protection.

SQL question Generate list of customers who had orders made in the summer of Tables needed: –customers, orders –JOIN … ON condition the natural one: when id fields match WHERE condition? –order date 'in' summer. Use BETWEEN Any grouping (aka aggregation)? –No GROUP BY. Instead, use DISTINCT

SQL question SELECT DISTINCT cname FROM customers as c JOIN orders as o ON c.cid = o.cid WHERE o.date BETWEEN ‘ ’ AND ‘ ’

SQL question What products were ordered by customers during Spring semester? Strategy: –decide on tables and ON conditions –determine dates and set up WHERE condition using BETWEEN –use DISTINCT

Left Join, etc. Searching for what is there and what isn't there. –Left Join –NOT EXISTS. You can create (on the fly) a new table and check if it has any rows. –See vs-not-exists-vs-left-join-is-null-mysql/ vs-not-exists-vs-left-join-is-null-mysql/

php: checking for value Using isset($_GET['guess']) is better than using $guess if ($guess != null) { }

php: strpos Check if string is present in another string $n = strpos($answer,"SUNY"); if ($n>-1) { } Alternative to regular expression

php: explode Breaks up string into an array if $listofstuff is "orange,apple,peach" $list = explode(",",$listofstuff); produces $list = ["orange","apple","peach"];

Database administrator technical: working with software, including maintaining security, performance. Keeping aware of changes in products, new products. administrative: working with technical staff AND other staff specific business: knowing and keeping up-to-date with knowledge of this business.

Internationalization & Localization How to make the php MySQL application work in different places character sets (includes symbols, encodings for symbols, collations (ordering rules) error messages (MySQL). Presumably your php code does error handling, also. time zone way to express dates See SET and SHOW commands

Reprise: Data base design Not obvious! Need to determine the information and the location of information in one or more tables. For each piece of information, what is the data type (representation) –different types of numbers –different types of character strings –MAY choose to incorporate media

Reprise: Database table design Consider orders by customer what information goes with the order and what information goes with the customer You do not want information associated with a customer to be repeated in every order! –wasteful of space –if (when) information changes, want to change in just one place

Maintenance of database Change fields in records Delete records Need to maintain referential integrity –Meaning that if a field in a table represents a foreign key (a reference to a record in another or this table), the referenced record exists!

Referential integrity Can handle in middleware (php) or MySQL or both. MySQL –CREATE statements specify field as FOREIGN KEY. Add clause saying what to do upon deletion ON UPDATE CASCADE ON UPDATE SET NULL ON UPDATE RESTRICT -- if there is a reference, an error will be generated. This is the default

Database Transaction refers to a sequence of operations on the database that are to be treated as a unit. Either they all go through or none go through. php MySQL has commands to implement transactions. –Turn off the 'auto-commit feature' –check each query if any problem, use mysqli_rollback() –when all okay, use mysqli_commit()

Project presentation Prepare and printout 1 pager: project name, members of team, abstract (1 paragraph summary), screen shot Show (corrected/improved/finalized) design diagrams –DFD and ERD Demonstrate Show storyboard –how project is implemented in html and php scripts Show and explain tricky parts of code.

Like SQL feature: stripped down regular expression –Wild card: % stands for 0, 1 or more letters SELECT * FROM states WHERE sname LIKE ‘North%’

Two forms of INSERT INSERT INTO customers VALUE (v1, v2,…vn) Where order of the values v’s is the order of the fields when the table was created INSERT INTO customers (fname, lname, zipcode) VALUES (‘Groucho’,’Marks’,10000)

QUIZ Take W3Schools SQL quiz t.asp?qtest=SQLhttp:// t.asp?qtest=SQL Or put sql quiz into Google.

Classwork/Homework Keep working on projects Postings (and respond to postings) on databases and related technologies in the news.