MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.

Slides:



Advertisements
Similar presentations
Session 2Introduction to Database Technology Data Types and Table Creation.
Advertisements

VTYS 2012 Mehmet Emin KORKUSUZ Ders  Create  Alter  Drop Data Defination Language.
Database Chapters.
MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Pertemuan ke 2 Tipe data & ERD Kurniawan Eka Permana.
May 26, 2005MySQL Tutorial - 11 MySQL Tutorial 1 – How to Use MySQL CSCI 2140 TA: Jiye Li May 26, 2005
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.
CIT 381 Data Types - data types - create table statement - constraints.
IMS1907 Database Systems Summer Semester 2004/2005 Lecture 9 Structured Query Language – SQL Data Definition Language - DDL.
Data Modelling. EAR model This modelling language allows a very small vocabulary: Just as English has nouns, verbs, adjectives, pronouns.., EAR models.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Creating Database Tables CS 320. Review: Levels of data models 1. Conceptual: describes WHAT data the system contains 2. Logical: describes HOW the database.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
SQL Basics+ Brandon Checketts. Why SQL? Structured Query Language Structured Query Language Frees programmers from dealing with specifics of data persistence.
1 CSE 480: Database Systems Lecture 9: SQL-DDL Reference: Read Chapter of the textbook.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
Copyright © Curt Hill SQL The Data Definition Language.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Lecture 9 – MYSQL and PHP (Part1) SFDV3011 – Advanced Web Development 1.
Creating Databases with MySQL Workbench Build the Forums database in Ullman’s Chapter 6.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Introduction to MySQL Lab no. 10 Advance Database Management System.
CSC 2720 Building Web Applications Database and SQL.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
Advanced Database Management System
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.
MySQL More… 1. More on SQL In MySQL, the Information Schema is the “Catalog” in the SQL standard SQL has three components: Data definition Data manipulation.
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.
Visual Programing SQL Overview Section 1.
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,
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Sql DDL queries CS 260 Database Systems.
Introduction to MySQL Lab no. 9 Advance Database Management System.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
1 CS 430 Database Theory Winter 2005 Lecture 11: SQL DDL.
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.
Relational Databases and MySQL. Relational Databases Relational databases model data by storing rows and columns in tables. The power of the relational.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Relational Databases and MySQL Charles Severance
Working with MySQL A290/A590, Fall /07/2014.
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Introduction to MySQL  Working with MySQL and MySQL Workbench.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Intro to MySQL.
Lecture 1.21 SQL Introduction Steven Jones, Genome Sciences Centre.
Database commands : DDL
CS320 Web and Internet Programming SQL and MySQL
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
MySQL-Database Jouni Juntunen Oulu University of Applied Sciences
CIS 136 Building Mobile Apps
Database Keys and Constraints
Referential Integrity MySQL
CS311 Database Management system
Database systems Lecture 2 – Data Types
CIS 136 Building Mobile Apps
CS122 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
Data Definition Language
Chapter 4 Introduction to MySQL.
CS3220 Web and Internet Programming SQL and MySQL
CS122 Using Relational Databases and SQL
Presentation transcript:

MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management

Relational Database Management System (RDBMS) Tools for: – Creating database – Managing database – Updating information –... Widely used RDBMS products – Oracle, DB2, Microsoft SQL Server, MySQL,...

MySQL Originally developed by Swedish MySQL AB using Open source Owned by Sun Microsystems nowadays Homepage Newest version 5.x

Managing (local) database server Start Apache and MySQL Press Admin (MySql) to open PHPMyAdmin Select language that you prefer Create new database

Exercise 1. 1.Open phpMyAdmin to manage local database server 2.Choose language that you prefer 3.Create new Database called Demox

Demox-database

Create tables Use graphical tool or SQL-statements

Defining fields with graphical tool

Exercise 2. Create table ProductGroup by using graphical tool

CREATE TABLE - example CREATE TABLE Class ( ID INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(10) UNIQUE NOT NULL ) TYPE=INNODB; CREATE TABLE tablename ( field1 datatype additional attributes, field2 datatype additional attributes, ) TYPE=INNODB; Example: Syntax:

Creating tables with SQL SQL-statements are NOT case-sensitive in MySQL (e. g. CREATE == create) There are many different syntax for doing things in SQL Naming tables and fields also varies

CREATE TABLE – data types Numbers – TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, FLOAT, DOUBLE Dates and time – DATE, TIME, DATETIME, TIMESTAMP, YEAR Strings and character – VARCHAR, CHAR, TEXT, BLOB, ENUM Boolean – TINYINT (0=false, 1=true), with new MySQL version BOOL and BOOLEAN is also available

CREATE TABLE – additional attributes PRIMARY KEY AUTO_INCREMENT UNSIGNED NOT NULL UNIQUE

Storage Engines in MySQL InnoDB – Foreign key constraints can be used MyISAM – Extremely fast, no foreign key constraints Blackhole – For testing...

Example: defining different datatypes and attributes create table Person( PersonId smallint unsigned auto_increment primary key, Name varchar(50) not null, varchar(100) unique not null, Saved timestamp default current_timestamp on update current_timestamp, Gender enum(’Male’,’Female’) ) type=innodb ;

Exercise 3. Create table Customer using SQL

Creating relationships CREATE TABLE Student ( ID INT AUTO_INCREMENT PRIMARY KEY,... class_ID INT NOT NULL, INDEX idx_class_ID (class_ID), FOREIGN KEY (class_ID) REFERENCES Class(ID) ON DELETE RESTRICT )

Exercise 4. Create table product using SQL-statement so that relationship between tables productgroup and product is created

Exercise 5. Create rest of the database Demox (tables Order and OrderRow) When creating table Order use syntax demox.Order (databasename.table), because order is reserved word in SQL (and therefore plain order won’t work).

Exercise 6. Create new database called guestbook Create table message with fields: – MessageID (primary key) – Message (text) – User (varchar) – Saved (timestamp)