ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: 12252 Week 3 – MySQL – Statements.

Slides:



Advertisements
Similar presentations
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Advertisements

® IBM Software Group © IBM Corporation QUY Thai Duy – ITFac DLU Lesson 2: The DB2 Environment.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Introduction to MySQL. 2 Road Map  Introduction to MySQL  Connecting and Disconnecting  Entering Basic Queries  Creating and Using a Database.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
How to Use MySQL CS430 March 18, SQL: “Structured Query Language”—the most common standardized language used to access databases. SQL has several.
Querying a Database Using the Select Query Window
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Integrating Databases into the Web with PHP/MySQL CS 4000.
Databases Ms. Scales. What is a Database? Database  A collection of data organized for fast search and retrieval  Examples: Telephone Directories Hospital.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Chapter 10: Working with Large Data Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
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.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
Present :Arezoo Mollahasani. Step 1  Define your server connection Open MySQL WorkBench and click New Server Instance on the right of the window.
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
What’s a database? Data stored in a structured format that lends itself to easy manipulation and recall.
CpSc 462/662: Database Management Systems (DBMS) MySQL.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
SQL has several parts: Major ones: DDL – Data Definition Language {Defining, Deleting, Modifying relation schemas} DML – Data Manipulation Language {Inserting,
Chungbuk HRDI of KCCI PhD Kang,Won-Chan PHP Programming (MySQL)
Relational Databases and MySQL. Relational Databases Relational databases model data by storing rows and columns in tables. The power of the relational.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Mysql YUN YEO JOONG. 1 Connecting to and Disconnecting from the Server 1 Connecting to and Disconnecting from the Server shell> mysql – h host -u user.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
Course Contents Overview: Database basics Lesson 1: Benefits of using a database Lesson 2: Table that data Lesson 3: Analyzing, viewing, and reporting.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 8 – Review Reference:
Marketing Analytics: Database Query with MySQL Disclaimer: All logos, photos, etc. used in this presentation are the property of their respective copyright.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
CCT395, Week 2 Introduction to SQL Yuri Takhteyev September 15, 2010
3 A Guide to MySQL.
Fundamentals of DBMS Notes-1.
Remote hosts and web servers
Web Systems & Technologies
Databases.
MySQL: Part II.
CCT1343, Week 2 Single-Table SQL Yuri Takhteyev University of Toronto
Introduction to MySQL.
Introduction to MySQL.
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Microsoft Office Access is the best –selling personal computer database management system. What is Access?
MySQL Database System Installation Overview SQL summary
Presentation transcript:

ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 3 – MySQL – Statements

1. databases A database is a structure that comes in two flavours: a flat database a relational database. A flat database is just stored on hard drives like a text file. A relational database is much more oriented to the human mind with a table-like structure. MySQL is a relational database.

Relational database (1) NameAgeWeight (kg) Height (meter) Telephone Bob Alice … …

Relational database There are tables that store data. The columns define which kinds of information will be stored in the table. An individual column must be created for each type of data you wish to store (i.e. Age, Weight, Height). On the other hand, a row contains the actual values for these specified columns. Each row will have 1 value for each and every column. NameAgeWeight (kg) Height (meter) Teleph one Bob Alice

Why use a database Storing information that fits into logical categories. Stores data in a systematic way. Information retrieval is made much easier, in particular in our current society with ‘Big Data’. For example, a student’s time tables. Student No Student Name DOB Module 1 ModuleLecturerLabClassTutor ITX2000GaoH105CG76Jerry Staff nameDepartmentOffice

Start MySQL Double click XAMPP-control.exe at folder ‘C:\xampp’. Open up a Command Prompt window ( type ‘cmd’ at search window). At the command prompt, do > cd c:\xampp\mysql\bin > mysql –u root

Basic statements of MySQL Create databases Need to login as a root (i.e., super user, no password (for the time being)) c:\> mysql –u root mysql> create database db; mysql> show databases; // to show how many databases mysql> use test; // use test database database Table 1 Table 2 Table 3 Table n

Create Tables  The columns specify what the data is going to be.  while the rows contain the actual data. (C = Column, R = Row)  In a real MySQL table only the value would be stored, not the R# and C#!  This table has 3 categories, or "columns", of data: Name, Age, and Weight.  This table has 4 entries, or in other words, four rows.

MySQL CREATE TABLE syntax CREATE TABLE tbl_name (C1-name type1, C2-name type2, C3-name type3.) Some DATA types: INT[(length)] INTEGER[(length)] REAL[(length,decimals)] DOUBLE[(length,decimals)] FLOAT[(length,decimals)] DATE TIME YEAR CHAR[(length)] VARCHAR(length)

MySQL CREATE TABLE syntax Use a CREATE TABLE statement to specify the layout of your table: mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); mysql> SHOW TABLES; | Tables in test | | pet |

Describe pet table

INSERT INTO (‘value’ or values’ are equally OK) mysql> INSERT INTO pet VALUES -> ('Puffball','Diane','hamster','f',' ',NULL); mysql> INSERT INTO pet VALUE -> ('Puffball','Diane','hamster','f',' ',NULL);

Select statement (1) mysql> select * from pet;//to view ALL the data in pet table;

Select statement (2) mysql> select name from pet;//To view only names in pet table;

Select statement (3) mysql> select name, species from pet;//To view both name and species in pet table;

Delete statement mysql> delete from pet where name=‘Fluffy’;// deleting first row. mysql> delete from pet where 1>0;// deleting all rows;

LOAD data into TABLE pet - Save following data into a file called “pet.txt”; For missing values (such as unknown sexes or death dates for animals that are still living), you can use NULL values. To represent these in your text file, use \N. For example, the record for Whistler the bird would look like this (where the whitespace between values is a single tab character): name owner species sex birth death Whistler Gwen bird \N \N

LOAD data into TABLE pet -Save ‘pet.txt’ at folder ‘c:\xampp\mysql\data\test’; mysql> LOAD DATA INFILE ‘pet.txt’ INTO TABLE pet;

Create table mysql> create table person (Name char(50), Age int, Weight int);

Ordering table data mysql> insert into person value(‘Alan’,76, 80.9); Mysql> select * from person order by Name; //Ascending order.

Ordering table data (1) mysql> SELECT name, weight FROM person ORDER BY birth;

Ordering table data mysql> SELECT name, weight FROM person ORDER BY birth DESC;

Ordering table data with multiple columns Sorting different columns in different directions. For example, to sort by type of animal in ascending order, then by birth date within animal type in descending order (youngest animals first), use the following query:

Summary MySQL