Bioinformatics Course Day 3 MySQL. Topics ● Databases ● MySQL ● SQL ● Permissions ● Usage ● Examples.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

MySQL Access Privilege System
3-1 Chapter 3 Data and Knowledge Management
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Chapter 4: Database Management. Databases Before the Use of Computers Data kept in books, ledgers, card files, folders, and file cabinets Long response.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Attribute databases. GIS Definition Diagram Output Query Results.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
1 Working with MS SQL Server II. 2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Computing for Bioinformatics Introduction to databases What is a database? Database system components Data types DBMS architectures DBMS systems available.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Database Lecture # 1 By Ubaid Ullah.
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
ASP.NET Programming with C# and SQL Server First Edition
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Introduction to SQL Steve Perry
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.
Ways to manage DB in MySQL cs346. Six ways to CREATE and INSERT INTO tables Modelocalremotelocalremotewindow WhereMysql console Putty; Mysql console Mysql.
1 Working with MS SQL Server Textbook Chapter 14.
MET280: Computing for Bioinformatics Introduction to databases What is a database? Not a spreadsheet. Data types and uses DBMS (DataBase Management System)
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Using Special Operators (LIKE and IN)
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
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.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
PHP and mySQL 2/9/2007. What is PHP?  From php.net “PHP is a widely-used general- purpose scripting language that is especially suited for Web development.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
Relational Databases: Basic Concepts BCHB Lecture 21 By Edwards & Li Slides:
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
IS6146 Databases for Management Information Systems Lecture 1: Introduction to IS6146 Rob Gleasure robgleasure.com.
CP476 Internet Computing Perl CGI and MySql 1 Relational Databases –A database is a collection of data organized to allow relatively easy access for retrievals,
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
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.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. DATABASE.
Relational Database Systems Bartosz Zagorowicz. Flat Databases  Originally databases were flat.  All information was stored in a long text file, called.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Introduction to Core Database Concepts Getting started with Databases and Structure Query Language (SQL)
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
Introduction to Database Programming with Python Gary Stewart
Marketing Analytics: Database Query with MySQL Disclaimer: All logos, photos, etc. used in this presentation are the property of their respective copyright.
SQL Introduction SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel – (Structured English.
3 A Guide to MySQL.
Fundamental of Databases
Web Systems & Technologies
CS320 Web and Internet Programming SQL and MySQL
Introduction to MySQL.
Database application MySQL Database and PhpMyAdmin
JDBC.
Chapter 7 Working with Databases and MySQL
Chapter 8 Working with Databases and MySQL
Database.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
CS3220 Web and Internet Programming SQL and MySQL
DATABASES WHAT IS A DATABASE?
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

Bioinformatics Course Day 3 MySQL

Topics ● Databases ● MySQL ● SQL ● Permissions ● Usage ● Examples

What are databases? ● DBMS (database management systems) ● Data storage and provision ● Software running on servers ● Designed for high-capacity, high-availability usage ● Relational, object-orientated, hierarchical, network model ● Examples: Oracle, PostgreSQL, MySQL, Sybase, DB2, dBASE, Microsoft SQL Server

What do they do? ● Record storing ● Indexing for quick access ● Data organization ● Data processing

Application areas ● BioPharma ● E-Commerce ● Education ● Energy ● Finance ● Government ● Media ● Retail ● Telecom ● Transport Anywhere with large data volumes!

MySQL Customers ● Bayer ● Sanger ● Ensembl ● Google ● Yahoo ● Ticketmaster ● Deutsche Post ● State of New York ● UNICEF ● Yamaha ● Wikipedia ● BT ● Nokiache Post ● Lufthansa

Why MySQL? ● World's most popular open source database ( 8 million active installations and 50,000 downloads per day) ● High-performance ● Reliable ● Ease of use ● Free!

What is SQL? ● Structured Query Language ● create, modify, retrieve and manipulate data ● 1970's IBM: Structured English Query Language ("SEQUEL"), later SQL ● simple command set ● intuitive

SQL Examples ● Most important: data selection SELECT name,sequence FROM swissprot WHERE name = 'TLR4_HUMAN'; DELETE FROM blast WHERE expect > 1e-20; UPDATE installs SET version = 8 WHERE db = 'uniprot'; ● Data update: INSERT INTO BLAST VALUES('TLR4_HUMAN', 'TLR4_PANPA', 1e-104); ● Data insertion: ● Data deletion:

MySQL setup MySQL Server MySQL Client MySQL Client MySQL Client MySQL Client MySQL Client MySQL Client local and remote access

MySQL accounts ● Administrator: root ● Users: kahokamp, guest1 (not necessarily the same as login names) ● Passwords: ******* (not necessarily the same as login passwords)

Permissions ● Assigned by administrator ● Multiple levels: – Access – Database usage – Select, Insert, Update, Delete, Drop,... ● May depend on host

Connection $ mysql -h localhost -u guest -p Command line access:

Connection $ mysql -h localhost -u guest -p MySQL client program server hostuser namepassword

Connection $ mysql -h localhost -u guest -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 427 to server version: standard-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>

Connection $ mysql -h bioinf.gen.tcd.ie -u guest -p uniprot Remote command line access: preselect a database

Connection use DBI; $user = 'guest'; $host = 'bioinf.gen.tcd.ie'; $password = ''; $db = 'uniprot'; $dbh = DBI->connect("DBI:mysql:database=$db;host=$host", $user, $password); $statement = “SELECT sequence FROM swissprot WHERE name = 'TLR4_HUMAN'”; $sth = $dbh->prepare($statement); $rv = $sth->execute; unless ($rv >= 1) { die “No match!”; } ($sequence) = $sth->fetchrow_array; print “$sequence\n”; Using Perl:

Connection use DBI; $user = 'guest'; $host = 'bioinf.gen.tcd.ie'; $password = ''; $db = 'uniprot'; $dbh = DBI->connect("DBI:mysql:database=$db;host=$host", $user, $password); $statement = “SELECT sequence FROM swissprot WHERE name = 'TLR4_HUMAN'”; $sth = $dbh->prepare($statement); $rv = $sth->execute; unless ($rv >= 1) { die “No match!”; } ($sequence) = $sth->fetchrow_array; print “$sequence\n”; Using Perl: database connection module access details connection query data retrieval

Connection Using the Web (PHPMyAdmin):

Orientation mysql> SHOW TABLES; | Tables_in_uniprot | | swissprot | row in set (0.00 sec) mysql> Show what's available:

Orientation mysql> SHOW DATABASES; | Database | | information_schema | | test | | uniprot | | uniprotKB8 | rows in set (0.00 sec) mysql> What other databases are there?

Orientation mysql> SHOW DATABASES; | Database | | information_schema | | test | | uniprot | | uniprotKB8 | rows in set (0.00 sec) mysql> USE TEST; Database changed mysql> What other databases are there?

Organization uniprottest swissprot test1test2 test4test3 MySQL Server databases tables

Permissions ● Creation of databases: – Normally only by administrator (root) ● Creation of tables: – All users with according permissions ● Special database 'test': – Normally accessible by all users ● Special user 'guest': – Limited access – Empty password

Work flow Create database Create of table(s) Insert data Query database

Table creation – Text – Numbers – Dates – Binary data – Sets Table columns need to be defined! Column types:

SQL Examples SELECT name,length FROM swissprot; | name | length | | 104K_THEAN | 893 | | 104K_THEPA | 924 | | 108_LYCES | 102 | | 10KD_VIGUN | 75 |... | ZYX_CHICK | 542 | | ZYX_HUMAN | 572 | | ZYX_MOUSE | 564 | rows in set (0.89 sec)

SQL Examples SELECT name,length FROM swissprot LIMIT 10; | name | length | | 104K_THEAN | 893 | | 104K_THEPA | 924 | | 108_LYCES | 102 | | 10KD_VIGUN | 75 | | 110KD_PLAKN | 296 | | 11S2_SESIN | 459 | | 11S3_HELAN | 493 | | 11SB_CUCMA | 480 | | 128UP_DROME | 368 | | 12AH_CLOS4 | 29 | rows in set (0.00 sec)

SQL Examples SELECT name,length FROM swissprot LIMIT ,10; | name | length | | ZYG12_CAEEL | 774 | | ZYG1_CAEBR | 709 | | ZYG1_CAEEL | 706 | | ZYGBL_HUMAN | 766 | | ZYGBL_MOUSE | 779 | | ZYGBL_PONPY | 766 | | ZYS3_CHLRE | 371 | | ZYX_CHICK | 542 | | ZYX_HUMAN | 572 | | ZYX_MOUSE | 564 | rows in set (0.60 sec)

SQL Examples SELECT name,length FROM swissprot ORDER BY length LIMIT 10; | name | length | | GWA_SEPOF | 2 | | ACI_TRIGI | 3 | | GRWM_HUMAN | 3 | | LUXE_VIBFI | 3 | | TRH_BOMOR | 3 | | TRH_NOTVI | 3 | | TRH_PIG | 3 | | TRH_SHEEP | 3 | | ACH1_ACHFU | 4 | | DCML_PSECH | 4 | rows in set (0.00 sec)

SQL Examples SELECT * FROM swissprot WHERE length = 2; | name | accession | version | dataset | created | modified | prot_name | component | type | lineage | tax_id | organism | checksum | length | seq_version | mass | seq_date | sequence | keyword | | GWA_SEPOF | P83570 | 15 | Swiss-Prot | | | Neuropeptide GWa | | | Eukaryota; Metazoa; Mollusca; Cephalopoda; Coleoidea; Neocoleoidea; Decapodiformes; Sepioidea; Sepiidae; Sepia | 6610 | Sepia officinalis (Common cuttlefish) | | 2 | 1 | 261 | | GW | Amidation; Direct protein sequencing; Neuropeptide | row in set (0.00 sec)

SQL Examples SELECT name,sequence,organism,prot_name FROM swissprot WHERE length = 2; | name | sequence | organism | prot_name | | GWA_SEPOF | GW | Sepia officinalis (Common cuttlefish) | Neuropeptide GWa | row in set (0.00 sec)

SQL Examples SELECT * FROM swissprot WHERE length = 2 \G *************************** 1. row *************************** name: GWA_SEPOF accession: P83570 version: 15 dataset: Swiss-Prot created: modified: prot_name: Neuropeptide GWa component: type: lineage: Eukaryota; Metazoa; Mollusca; Cephalopoda;... tax_id: 6610 organism: Sepia officinalis (Common cuttlefish) checksum: length: 2 seq_version: 1 mass: 261 seq_date: sequence: GW keyword: Amidation; Direct protein sequencing; Neuropeptide 1 row in set (0.01 sec)

SQL Examples SELECT name,length FROM swissprot ORDER BY length DESC LIMIT 10; | name | length | | DIG1_CAEEL | | | SYNE1_HUMAN | 8797 | | ANC1_CAEEL | 8545 | | UNC89_CAEEL | 8081 | | OBSCN_HUMAN | 7968 | | LGRC_BREPA | 7756 | | BPA1_MOUSE | 7389 | | R1AB_CVMJH | 7180 | | R1AB_CVMA5 | 7176 | | R1AB_CVM2 | 7124 | rows in set (0.00 sec)

SQL Examples SELECT name,length FROM swissprot WHERE length < 10; | name | length | | GWA_SEPOF | 2 | | ACI_TRIGI | 3 | | GRWM_HUMAN | 3 | | LUXE_VIBFI | 3 |... | UPA7_HUMAN | 9 | | XYLA_STRS8 | 9 | | YBFR_AZOVI | 9 | rows in set (0.01 sec)

SQL Examples SELECT COUNT(*) FROM swissprot WHERE length < 10; | count(*) | | 365 | row in set (0.00 sec)

SQL Examples SELECT DISTINCT length FROM swissprot WHERE length < 10; | length | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | rows in set (0.00 sec)

SQL Examples SELECT length, COUNT(length) FROM swissprot WHERE length < 10 GROUP BY length; | length | COUNT(length) | | 2 | 1 | | 3 | 7 | | 4 | 22 | | 5 | 30 | | 6 | 18 | | 7 | 50 | | 8 | 103 | | 9 | 134 | rows in set (0.00 sec)

SQL Examples CREATE TABLE test.splen SELECT length, COUNT(length) FROM swissprot GROUP BY length; Query OK, 2717 rows affected (0.30 sec) Records: 2717 Duplicates: 0 Warnings: 0

SQL Examples SELECT * FROM test.splen ORDER BY `COUNT(length)` DESC LIMIT 10; | length | COUNT(length) | | 379 | 1004 | | 146 | 921 | | 141 | 749 | | 156 | 694 | | 148 | 633 | | 207 | 591 | | 155 | 590 | | 152 | 579 | | 215 | 573 | | 119 | 570 | rows in set (0.01 sec)

SQL Examples SELECT name,organism FROM swissprot WHERE NAME LIKE 'TLR4\_PA%'; | name | organism | | TLR4_PANPA | Pan paniscus (Pygmy chimpanzee) | | TLR4_PAPAN | Papio anubis (Olive baboon) | rows in set (0.00 sec) Wild-cards: _ (single character) %(multiple characters) Escape with backslash (\)!

SQL Examples SELECT name,organism FROM swissprot WHERE NAME LIKE 'tlr4\_PA%'; | name | organism | | TLR4_PANPA | Pan paniscus (Pygmy chimpanzee) | | TLR4_PAPAN | Papio anubis (Olive baboon) | rows in set (0.00 sec) Case-insensitive (unless binary format)!

SQL Examples SELECT name,organism FROM swissprot WHERE NAME = 'TLR__PANPA'; Empty set (0.00 sec)

SQL Examples SELECT name,organism FROM swissprot WHERE NAME LIKE 'TLR__PANPA'; | name | organism | | TLR4_PANPA | Pan paniscus (Pygmy chimpanzee) | row in set (0.00 sec)

SQL Examples SELECT name,length FROM swissprot WHERE NAME REGEXP '^TLR[4-9]\_HUMAN'; | name | length | | TLR4_HUMAN | 839 | | TLR5_HUMAN | 858 | | TLR6_HUMAN | 796 | | TLR7_HUMAN | 1049 | | TLR8_HUMAN | 1041 | | TLR9_HUMAN | 1032 | rows in set (0.00 sec)

Normalization ● Optimize database design ● Avoid duplication of data ● Least redundancy in tables

Normalization Bad design! Repetition of entries, difficult to index and awkward to search

Normalization Alternative Design: Not optimal either: different number of keywords for each entry still very repetitive

Normalization Normalized version: Select name,sequence FROM table1, table2, table3 WHERE keyword = 'Glycoprotein' AND ID = ID1 AND ID2 = name

Normalization Normalized version: Select name,sequence FROM table1, table2, table3 WHERE keyword = 'Glycoprotein' AND ID = ID1 AND ID2 = name

More Info ● MySQL tutorials on the web ● Learning MySQL (O'Reilly) ● (searchable and browsable on-line)