IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

Similar documents
PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

More loops. Control structures / flow control. while loops. Loops / Iteration / doing things over and over and over and over...

Locate your Advanced Tools and Applications

PHP. How Web Applications interact with server side databases CRUD. Connecting and using mysql from PHP PHP provides many mysql specific functions

Server side scripting and databases

PHP Development - Introduction

Module 3 MySQL Database. Database Management System

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist.

CSC 3300 Homework 3 Security & Languages

Unit 27 Web Server Scripting Extended Diploma in ICT

Chapter 6 Part2: Manipulating MySQL Databases with PHP

By the end of this section of the practical, the students should be able to:

CHAPTER 10. Connecting to Databases within PHP

MySQL: Access Via PHP

Databases and SQL. Lecture outline. CSE 190 M (Web Programming) Spring 2008 University of Washington

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly

Mount Saint Mary College, Newburgh, NY Internet Programming III - CIT310

Jackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 3

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

A QUICK GUIDE TO PROGRAMMING FOR THE WEB. ssh (then type your UBIT password when prompted)

LABSHEET 1: creating a table, primary keys and data types

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015

Introduction to relational databases and MySQL

MYSQL DATABASE ACCESS WITH PHP

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

Comparison with MySQL

Database Connectivity using PHP Some Points to Remember:

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

Chapter. Accessing MySQL Databases Using PHP

Database Systems. phpmyadmin Tutorial

PHP Tutorial 6(a) Using PHP with MySQL

Server 2 - MySQL #1 Lab

Courtesy of Clayton Fyfe. Lab 2 Runthrough

3344 Database Lab. 1. Overview. 2. Lab Requirements. In this lab, you will:

What is SQL? Toolkit for this guide. Learning SQL Using phpmyadmin

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity]

Understanding Basic SQL Injection

PHP Arrays. Lecture 18. Robb T. Koether. Hampden-Sydney College. Mon, Mar 4, 2013

SQL stands for Structured Query Language. SQL lets you access and manipulate databases

CS 377 Database Systems. Li Xiong Department of Mathematics and Computer Science Emory University

Review a Sample Database Using a SQLyog MySQL GUI Tool

PHP: Hypertext Preprocessor. A tutorial Introduction

Mastering phpmyadmiri 3.4 for

PHP DBTreeView User manual

Oracle Database 10g Express

Infotek Solutions Inc.

Host at 2freehosting.Com

Systems Programming & Scripting

A340 Laboratory Session #17

Mysql Tutorial Show Table Like Name Not >>>CLICK HERE<<<

Download and Installation Instructions: After WAMP Server download start the installation:

Princess Nourah bint Abdulrahman University. Computer Sciences Department

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

2017 Politecnico di Torino 1

2017 Politecnico di Torino 1

CRAF RFI Database: a MySQL implementation

INSTALLING RACHEL ON SYNOLOGY GIAKONDA IT

AN INTRODUCTION TO WEB PROGRAMMING. Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

Chapter 3 Introduction to relational databases and MySQL

Databases. Web applications in PHP to query a database. Practice n. 4

Using MySQL on the Winthrop Linux Systems

This lecture. PHP tags

Database Application Programs PL/SQL, Java and the Web

Databases PHP I. (GF Royle, N Spadaccini ) PHP I 1 / 24

Application Links. Chapter 7.1 V3.0. Napier University Dr Gordon Russell

Create Basic Databases and Integrate with a Website Lesson 3

TopView SQL Configuration

Using PHP with MYSQL

Working with Databases

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

php Mr. Amit Patel Hypertext Preprocessor Dept. of I.T.

Database connection 1

Introduction of PHP Created By: Umar Farooque Khan

PHP Arrays. Lecture 20. Robb T. Koether. Hampden-Sydney College. Wed, Feb 28, 2018

MySQL On Crux Part II The GUI Client

Module - P7 Lecture - 15 Practical: Interacting with a DBMS

Lecture 13: MySQL and PHP. Monday, March 26, 2018

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information.

Creating Your First MySQL Database. Scott Seighman Sales Consultant Oracle

Full version is >>> HERE <<<

Publish Joomla! Article

Publish Joomla! Article

CGS 3066: Spring 2017 SQL Reference

Lecture 7: Web hacking 3, SQL injection, Xpath injection, Server side template injection, File inclusion

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7

Web-based IDE to create Model and Controller Components for MVC-based Web Applications on CakePHP

Database Management Systems Design. Week 6 MySQL Project

Networks and Web for Health Informatics (HINF 6220)

ITC 250/CPET 499 Web Systems Nov. 3, 2016 Managing MySQL Database Part 3 of 3

Announcements. PS 3 is out (see the usual place on the course web) Be sure to read my notes carefully Also read. Take a break around 10:15am

Php And Mysql Manual Simple Yet Powerful Web Programming

A practical introduction to database design

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Quick Guide to Installing and Setting Up MySQL Workbench

Linux Network Administration. MySQL COMP1071 Summer 2017

Building an E-mini Trading System Using PHP and Advanced MySQL Queries ( ) - Contributed by Codex-M

SQL DDL. Intro SQL CREATE TABLE ALTER TABLE Data types Service-based database in Visual Studio Database in PHPMyAdmin

Manipulating Database Objects

Lecture 8. Database vs. Files SQL (I) Introduction to SQL database management systems (DBMS)

Transcription:

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population In this lab, your objective is to learn the basics of creating and managing a DB system. One way to interact with the DBMS (MySQL) is to use the GUI provided by MySQL. However, we shall use a separate interface, phpmyadmin for most tasks in this lab and the next one. Objectives of lab 5. (a) Learn to create a database (b) Learn to create tables in the database. Objectives of lab 6. (a) Learn to populate you DB tables. (b) Learn the basics of developing a DB API using PHP CGI's. As before, if you need to look up the syntax of some SQL command, you can use a good online tutorial site, such as: http://www.w3schools.com/sql Step 5.1. Create a DB using phpmyadmin. Before running this task, note that you should create a user account in MySQL, and assign a password to the user. When you start phpmyadmin, you will be presented with a screen something like: Use the link for "Create new database" to create a database called "bank". After creating the database, click on the DB name, and then you can start creating tables. Step 5.2. Create tables using phpmyadmin. You will learn three ways to create tables (two methods in lab 5, one in lab 6)

1. Using the GUI of phpmyadmin program. 2. Using a SQL CREATE TABLE command issued from phpmyadmin GUI. 3. Using a CGI program to connect to your MySQL DB, and sending the command from your CGI program Before you create any table(s), please do your planning: - Names of all the tables. - All the attributes for each table - The domain constraint(s) for each attribute - The primary key for each table - The referential constraints (Foreign keys) Conventions: Try to use a consistent convention for all names that you will assign. For example: All table names: First letter capitalized with no underscores: e.g. Loan. All attribute names: lower case with underscores: name, ssn, start_date. All constraint names: lower case, underscored; for example, a foreign key constraints from in table Loan fk_loan_c1, etc. 1. How to use phpmyadmin to create your own table? 1. Login in to phpmyadmin, click on the database name on the left-hand-side 2. Enter the table name and number of fields, then click 'Go'.

3. For each attribute (field), enter the name and specify the type, length, set the primary key, etc.; Click on Save to create the table. Conventions: I suggest use only three data types: VARCHAR, DOUBLE and DATE. Task: Use this method to create the 'Branch' table from your lecture notes. 2. How to use SQL command to create tables using phpmyadmin 1. Click on the SQL tab (blue color) from any page of phpmyadmin 2. Type your SQL command in a TXT file. Load the TXT file as below, and click 'Go'. bank localhost bank (-) Type your SQL create table.. command in a TXT file. Use this interface to load the query in this box Task: Use this method to create all the tables of the 'bank' database from the lecture notes. Step 6.1. Populate the tables using phpmyadmin. There are several ways to insert rows of data into a table: 1. Using the GUI provided by phpmyadmin: - select the table - click on the "Insert" button, and - enter the data.

b_namechar(30) city char(60) assets double enter values here 2. The preferred way for this lab: Use the "insert into " command of SQL, and type all the store data commands into a TXT file3. Then load the file into the SQL interface and run it. 3. It may be possible to import the data from some previously exported DB file (or even from text or Excel files however, you should not use that method for this lab. Task: Use this method to populate all the tables you have created. For the tables in the lecture notes, please use the same data as given (this will be later useful to test your homework solutions!). For other tables, please use data consistent with the notes and the design. Step 6.2. Learn the basics of developing a DB API using PHP CGI's. In this lab, we will first learn the simplest method for a PHP program to connect to the MySQL database. For now, you can use a modified version of the following PHP script, and execute it directly from the phpdesigner (or compile it and run it from your local host. NOTE: modify the portions that are in bold black. <?php $hostname = 'localhost'; $username = 'root'; $password = "password"; $link = mysql_connect( $hostname, $username, $password ) or die("could not connect : ". mysql_error()); echo "Connected successfully!"; $mydb = "dbname";

$db = mysql_select_db( $mydb ) or die("could not select database"); echo "Database ". $mydb. " selected."; // Note: values that are of type char( ) must be quoted; numbers are not in quotes. $query = "insert into mytable values( 'v1', 'v2', v3)"; $result = mysql_query($query) or die("query failed: ". mysql_error()); /* $result is a special data structure; the function mysql_fetch_assoc is used to convert the returned table into a PHP associative array. */ while ($row = mysql_fetch_assoc($result)) { echo $row['column_name_1']; echo $row['column_name_2']; echo $row['column_name_3']; } mysql_close($link);?> References: 1. HTML quick reference file. 2. PHP tutorials and function references: (from www.php.net) 3. PHP tutorial site: http://www.w3pop.com/learn/view/p/3/o/0/doc/php_ref_string/ 4. Another PHP tutorial/reference: http://www.w3schools.com/php/php_ref_array.asp 5. MySQL tutorial/reference: http://www.w3schools.com/sql Lab materials for IELM 511 prepared by WEI Xiangzhi, Dept of IELM, HKUST.