Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
How to Create a Local Collection
CC SQL Utilities.
Database Chapters.
Pertemuan ke 2 Tipe data & ERD Kurniawan Eka Permana.
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
Uploading a Turnitin Assignment Faculty of Humanities and Social Sciences.
MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Creating Database Tables CS 320. Review: Levels of data models 1. Conceptual: describes WHAT data the system contains 2. Logical: describes HOW the database.
Downloading and Installing AutoCAD Architecture 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the software.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.
ADVM420- Class #4 Web Design with PHP and MySQL Adding and Listing from a MySQL Database.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Copyright © Curt Hill SQL The Data Definition Language.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Week Four CIT 354 Internet II. 2 Objectives Uploading Files to Your Web Site Establishing a Connection Creating a Database Table Common Programming Errors.
Welcome to Minnesota’s eFolio Rochester Workforce Center September 12, 2003 Norman Baer Matthew St. Martin.
© 2003 By Default! A Free sample background from Slide 1 Week 2  Free PHP Hosting Setup  PHP Backend  Backend Security 
Log on to Digital Locker Website You should be able to log on using Internet Explorer browser at the campus. You may need to log in using Mozilla FireFox.
Frank Hilhorst President Progressive Consulting Inc. Open Source Data Sharing.
PHP meets MySQL.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
LIS651 lecture 6 mySQL Thomas Krichel
Introduction to MySQL Lab no. 10 Advance Database Management System.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
Creating databases for web applications Database datatypes. Creating database Homework: Create tables in database. Add records to database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 2720 Building Web Applications Database and SQL.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Website Development with PHP and MySQL Saving Data.
Transforming TurboIMAGE Data for Eloquence, Oracle, and More By Bob Green, Robelle
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
14. Uploading Files to MySQL Database. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan.
XRX Basic CRUDS Create, Read, Update and Delete and Search XML Data Date: May 2011 Dan McCreary President Dan McCreary & Associates
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
Fox MIS Spring 2011 Database Week 6 ERD and SQL Exercise.
12/14/20151 Uniquescriptz Backend Support Document Ver 2.0.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Sql DDL queries CS 260 Database Systems.
MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.
 Empowers to your customer  Product Rating and its Management in Ecommerce Framework  Product Reviews and Management: Collecting customer opinion about.
Mr C Johnston ICT Teacher
Introduction to MySQL Lab no. 9 Advance Database Management System.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
This is the software we will use to load our html page up to the server. You can download a copy for home if you want to.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Intro to MySQL.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
SQL and SQL*Plus Interaction
Storing Images Connect to the server using the correct username and password. $conn = mysql_connect(“yourserver”, “joeuser”, “yourpass”); Create the database.
Database application MySQL Database and PhpMyAdmin
PHPMyAdmin.
Database systems Lecture 2 – Data Types
Chapter 4 Introduction to MySQL.
MySQL Database System Installation Overview SQL summary
Kirkwood Center for Continuing Education
Database Instructor: Bei Kang.
Presentation transcript:

Class 3Intro to Databases Class 4 Simple Example of a Database We’re going to build a simple example of a database, which will allow us to register users and allow them to log in to do this, we’re going to 1- design a database that fits our needs 2- create templates that allow us to view and enter information 3- enter records into the database 4- write scripts that allow us to a- view the information b- enter the information

Class 3Intro to Databases Class 4 Project To create our database and the tables for this project, we need to understand what our project will be. Project Description Create a system that allows 1- new users to register 2- existing users to login 3- existing users to change their passwords 4- existing users to view all users

Class 3Intro to Databases Class 4 DESIGNING THE SITE (from a programming point of view)

Class 3Intro to Databases Class 4 Site Map A Site Map is an overall look at the pages & links within a site from a users point of view. It indicates how users can get from point A to point B.

Class 3Intro to Databases Class 4 What the site will look like image here

Class 3Intro to Databases Class 4 Site Flow The Site Flow is an overall look at the pages & links within a site from a programming point of view. It indicates how the program flows from point A to point B.

Class 3Intro to Databases Class 4

Class 3Intro to Databases Class 4 Site IA The Information Architecture describes 1- the elements that make up a page and 2- how they function

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA REGISTER has 2 states Form Confirm

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA LOGIN has 2 states Form Confirm

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA CHANGE PASSWORD has 2 states Form Confirm

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Site IA VIEW USERS has only one state

Class 3Intro to Databases Class 4 Site IA

Class 3Intro to Databases Class 4 Directory Structure The directory structure outlines where files will be stored.

Class 3Intro to Databases Class 4 CREATING THE TEMPLATE

Class 3Intro to Databases Class 4 Creating the template

Class 3Intro to Databases Class 4 Creating the template Content.... "); //FOOTER include ('./templates/footer.php'); // Include the HTML footer. ?>

Class 3Intro to Databases Class 4 Creating the template PHP has 4 functions for using external files include() include_once() require() require_once To use them, your script needs a line like include (‘filename.php'); What’s the difference? If an include file is not found it will display an error, but other scripts will run if a require file is not found, it will display and error and the other scripts will NOT run include_once() and require_once will be called only once, no matter how many times your scripts refer to them

Class 3Intro to Databases Class 4 Creating the header file Welcome to my site! Home Register

Class 3Intro to Databases Class 4 Creating the footer file Home Register © 2003 Larry E. Ullman and DMC Insights, Inc.

Class 3Intro to Databases Class 4 WRITING THE SCRIPTS

Class 3Intro to Databases Class 4 Writing the scripts Preciously we used 2 scripts to handle our HTML forms. One to display the form One to process it Using some of the logic we learned last week, we’re going to combine both of these processes into one form.

Class 3Intro to Databases Class 4 Writing the scripts

Class 3Intro to Databases Class 4 Writing the scripts Display the footer User defined functions Display the header Check if form has been submitted If YES, do error checking If NO, display form Does information pass error checking? If YES, register user and print confirm message If NO, display error message and form

Class 3Intro to Databases Class 4 Writing the scripts 0) { } else { $error_message.= " You forgot to enter your username! "; } // Do I PASS ERROR CHECKING? if ($error_message=="" ) { // If everything's okay. // Register the user. // DATABSE FUNCTIONALITY WILL GO HERE //print verification/confirm message } else { // There's an error. //print error message print_registration_form(); } } else { // Display the form. print_registration_form(); } // End of the main SUBMIT conditional. include ('./templates/footer.php'); // Include the HTML footer. function print_registration_form(){ … } ?> Display the footer User defined functions Display the header Check if form has been submitted If YES, do error checking If NO, display form Does information pass error checking? If YES, register user and print confirm message If NO, display error message and form

Class 3Intro to Databases Class 4 DESIGNING THE DATABASE & TABLE

Class 3Intro to Databases Class 4 What the table will look like This table is relatively simple. 1- We have one main “type” of thing to worry about –users, so we’re going to create one table 2- From the IA we know there are 7 things we need to have for each user First Name Last Name User Name Password User ID (gives us a way to uniquely id each user) Registration Date

Class 3Intro to Databases Class 4 What the table will look like To fully construct our table we need to define the data type required by each column. My SQL has a number of data types, but they break down into a few basic categories BOOLEAN NUMBERS Integer, Float, Decimal etc DATE Datetime, Timestamp, etc TEXT Char, Varchar, Text, Blob

Class 3Intro to Databases Class 4 Data Types have to be correct – otherwise you will be trying to put a square peg in a round hole. Once in a while it will work, but often it will be impossible.

Class 3Intro to Databases Class 4 These are further broken down, usually by the how much information each variable can store BOOLEAN - no sub categories NUMBERS TINYINT - A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255 SMALLINT - A small integer. The signed range is to The unsigned range is 0 to MEDIUMINT - A medium-size integer. The signed range is to The unsigned range is 0 to INT- A normal-size integer. The signed range is to The unsigned range is 0 to BIGINT - A large integer. The signed range is to The unsigned range is 0 to

Class 3Intro to Databases Class 4 What the table will look like NUMBERS (cont’d) FLOAT- A small (single-precision) floating-point number. Allowable values are E+38 to E-38, 0, and E-38 to E+38. DOUBLE - A normal-size (double-precision) floating-point number. Allowable values are E+308 to E-308, 0, and E-308 to E+308. DECIMAL- An unpacked floating-point number. Behaves like a CHAR column: ``unpacked'' means the number is stored as a string, using one character for each digit of the value.

Class 3Intro to Databases Class 4 What the table will look like TEXT VARCHAR - A variable-length string. The range is 0 to 255 characters (1 to 255 prior to MySQL Version 4.0.2). TINYBLOB TINYTEXT - A BLOB or TEXT column with a maximum length of 255 characters. BLOB TEXT A BLOB or TEXT column with a maximum length of characters. MEDIUMBLOB MEDIUMTEXT A BLOB or TEXT column with a maximum length of (2^24 - 1) characters. LONGBLOB LONGTEXT A BLOB or TEXT column with a maximum length of or 4G (2^32 - 1) characters.

Class 3Intro to Databases Class 4 What Data Type to use for each column? This is always a tricky question. For our example let’s go back to the project IA and some common sense. First Name - Since the IA says that this has a max number of 30 characters and it’s a text string, I’m going to make it a VARCHAR with a max of 30 characters Last Name- Since the IA says that this has a max number of 30 characters and it’s a text string, I’m going to make it a VARCHAR with a max of 30 characters Name- Since the IA says that this has a max number of 255 characters and it’s a text string, I’m going to make it a VARCHAR with a max of 255 characters User Name- Since the IA says that this has a max number of 10 characters and it’s a text string, I’m going to make it a VARCHAR with a max of 10 characters

Class 3Intro to Databases Class 4 What Data Type to use for each column? Password - Since the IA says that this has a max number of 10 characters and it’s a text string, I’m going to make it a VARCHAR with a max of 10 characters User ID – This is going to be a unique number for each user. I can’t imagine I’m going to have more than users, so I’m going to make it a MEDIUM INT unsigned Registration Date– I want to get both the date and time a user registered, so I’m going to make it a DATETIME type

Class 3Intro to Databases Class 4 What Data Type to use for each column? This is the DATASPEC to design our table Also PRIMARY KEY

Class 3Intro to Databases Class 4 CREATING THE TABLE

Class 3Intro to Databases Class 4 Creating a Database We’re going to use phpMyAdmin to create our database.

Class 3Intro to Databases Class 4 Installing phpMyAdmin 1- download phpMyAdmin 2- unzip the file 3- rename the folder phpMyAdmin 4- changes to config.inc.php

Class 3Intro to Databases Class 4 Installing phpMyAdmin config.inc.php The directory for phpMyAdmin on your site For example The user name & password from Kunal

Class 3Intro to Databases Class 4 Installing phpMyAdmin 5- upload the folder phpMyAdmin 6- go to the full url you used for example

Class 3Intro to Databases Class 4 Using phpMyAdmin creating a database

Class 3Intro to Databases Class 4 Using phpMyAdmin creating a table Name – is arbitrary, but it should make some sense Number of fields – we know this from our dataspec –

Class 3Intro to Databases Class 4 Using phpMyAdmin naming columns and assigning datatypes Field Name – should come from our dataspec Type – we know this from our dataspec Length/Values – we know this from our dataspec Extra– we know this from our dataspec Key – we know this from our dataspec –

Class 3Intro to Databases Class 4 Using phpMyAdmin naming columns and assigning datatypes –

Class 3Intro to Databases Class 4 Using phpMyAdmin –

Class 3Intro to Databases Class 4 Using phpMyAdmin entering records – Click this to enter a record Leave this blank – we’re using Auto Increment

Class 3Intro to Databases Class 4 Using phpMyAdmin viewing records – Click this to view records