Presented by: Teererai Marange

Slides:



Advertisements
Similar presentations
MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Advertisements

2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Introduction to Structured Query Language (SQL)
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.
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.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 2: Single-Table Selections.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
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.
Introduction to SQL  SQL or sequel  It is a standardised language with thousands of pages in the standard  It can be in database system through GUI,
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Oracle Data Definition Language (DDL)
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
INTERNET APPLICATION DEVELOPMENT For More visit:
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
PHP meets MySQL.
Introduction to databases and SQL. What is a database?  A database is an organized way of holding together pieces of information  A database refers.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
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.
CSC 2720 Building Web Applications Database and SQL.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
CMPT 258 Database Systems The Relationship Model (Chapter 3)
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
Structured Query Language SQL-II IST 210 Organization of Data IST2101.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
 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.
3 A Guide to MySQL.
Web Systems & Technologies
SQL Query Getting to the data ……..
CompSci 280 S Introduction to Software Development
Chapter 5 Introduction to SQL.
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Module 2: Creating Data Types and Tables
Introduction to Structured Query Language(SQL)
Using the Set Operators
ISC440: Web Programming 2 Server-side Scripting PHP 3
Introduction To Structured Query Language (SQL)
SQL.
Section 4 - Sorting/Functions
Using the Set Operators
The University of Akron College of Applied Science & Technology Dept
Shelly Cashman: Microsoft Access 2016
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

Presented by: Teererai Marange COMPSCI 280 : tutorial 1 Presented by: Teererai Marange

Agenda $whoami Admin details Some Tips Intro to lab 1 Revision exercises Huddle More revision exercises

$whoami My name is Terry. My background: Originally from a business background. Used to trade options and shares for a living. Made some observations that led to my switch to Compsci. Currently a Phd student in Computer Science. My research focus: Data Structures and Algorithms. Artificial intelligence. Most importantly I will be your tutor.

Admin details My email: t.marange@Auckland.ac.nz My office hours: Every Tuesday between 12 and 1pm in rm 303-375 I will also be available at lab 303s-G91 btw 8am and 12pm on every Wednesday. I will also be answering queries on Canvas. Ideally please post your questions here so everyone can see them.

Some tips Practise makes perfect. Every technology has a use case and limitations. Try to pick out the use cases Try to look for limitations as well. If in doubt, ask. If I’m moving too fast or too slow let me know. I welcome feedback on topics covered or any topics of interest that you would like to discuss briefly. Ideally start assignments and labs ASAP.

Introduction What is a database?  A collection of related data stored in a manner so it can be retrieved as needed. Why a database? Reduced duplication and better control over data consistency. Concurrency control. Recovery. Security. Centralized control. Platform independence. Encourage good data management practices.

Use case 1: local database App and database stored on the same device

Use case 2: Remote database Scales better.

SQL SQL (Structured query language) A language for interacting with a relational database. High level language Declarative(As opposed to procedural). User specifies what they want done ignoring how. This is put in a command called a query.

Let’s talk about Lab 1: 3 databases: Let’s connect to each. Sdf file(local) MySQL(remote) MS SQL Server(remote) Let’s connect to each. You are required to Create a table on each. Insert records into each. Use select Query to check that your records and table have been persisted to the databases.

Create table: Structure: CREATE TABLE some_table ( Constraints: Column_name1 data_type_1 [optional constraints] Column_name2 data_type_1 [optional constraints] … ); Constraints: NOT NULL: value should not be null. UNIQUE: All values in column must be unique. DEFAULT.  Assigns value to attribute when a new row is added to table

MYSQL datatypes(Using Putty SQL client): Characters: CHAR(20), VARCHAR(50)  Char: Holds a fixed length string Varchar: Holds a variable length string  Numbers: INT, BIGINT, SMALLINT, FLOAT Others: DATE, DATETIME

SQL CE Datatypes(Using Linqpad): Characters: NCHAR(20), NVARCHAR(50)  nChar: Holds a fixed length string nVarchar: Holds a variable length string  Numbers: INT, BIGINT, SMALLINT, FLOAT Others: DATE, DATETIME

Exercises: We will be using the Northind.sdf database file so download it from canvas and connect to it using linqpad.

Exercise: 1 A. Write a SQL statement to create a table named countries including columns country_id,country_name and region_id. Make sure that no all values of country_id will be unique. The default value for country_name is Zimbabwe and a value must be entered for region_id.

Exercise: 1

Exercise: 1 After clicking the play button, right click the database in question and then click refresh.

Exercise: 1 Notice that the countries table appears on the left hand side.

Exercise: 1 After pressing the play button, right click the database in question and then click refresh.

Insert Method 1: Specifies a value for each column of the table   Specifies a value for each column of the table Values MUST be in the same order as the columns of the table Method 2: Put values in a few columns of the table.

Exercise 2: A. Enter the following and then press play.

Exercise 2: A. Now check whether the record is in the table. Enter the code below and then click play. You should see the results below.

Exercise 2: C. Now reenter the insert query from before and press play. You should receive the following error. This is because you are attempting to inserta duplicate record.

Exercise 2: A. Enter the following and then press play.

Select statement Used to retrieve data from a table. 6 parts SELECT [DISTINCT] Column_1, [Column_2, Column_3, …] FROM Table_Name [WHERE Clause] [GROUP BY Clause] [HAVING CLAUSE] [ORDER BY Clause]

SELECT SELECT [DISTINCT] Column_1, [Column_2, Column_3, …] Which columns we want to see in results table. Column list can be *(meaning all columns in the order they are in the original table) Result table has columns in the order given. Aliases allowed Eg. Column 1 AS Name Optional DISTINCT clause retrieves unique records on the results tables.

WHERE Clause A statement that returns true for all rows in the result table. Examples WHERE manager_id=203 WHERE manager_id IN (203, 204, 210) WHERE manager_id BETWEEN 203 and 210 What are the boundaries. WHERE last_name LIKE ‘%M_ar%’ Note: We can use connectors like AND OR and NOT

WHERE Clause A statement that returns true for all rows in the result table. Examples WHERE manager_id=203 WHERE manager_id IN (203, 204, 210) WHERE manager_id BETWEEN 203 and 210 What are the boundaries. WHERE last_name LIKE ‘%M_ar%’ Note: We can use connectors like AND OR and NOT

ORDER BY Specifies a sort order for columns: Structure: ORDER BY Column 1, [Column 2, …., Column n] [ASC or DESC] Works in the order of the columns listed ie. First try to arrange column in order of Column 1 but if Column 1 matches for 2 or more records then order by Column 2.

Exercises 3 Write a Query to show all records in the Customers table in Ascending order of the ContactTitle. List all distinct values of ContactTitle in Ascending order of color. List the the OrderID, Order Date and Required Date for all Orders in the Orders table whose OrderID is between 10248 and 10257 List all Countries of origin of all Customers whose name has and k in it. There should be no duplicate values in the results. List all Cities whose name starts with an r or an o in the customers table.

Exercises 3 Write a Query to show all records in the Customers table in Ascending order of the ContactTitle.

Exercises 3 Enter the following and then click play. You should see the following in the results tab.

Exercises 3 2. List all unique values of ContactTitle in the Customers table in Descending alphabetic order.

Exercises 3 2. Enter the following and then click play. You should see the following in the results tab.

Exercises 3 List the the OrderID, Order Date and Required Date for all Orders in the Orders table whose OrderID is between 10248 and 10257

Exercises 3 2. Enter the following and then click play. You should see the following in the results tab.

Exercises 3 List all Countries of origin of all Customers whose name has k in it. There should be no duplicate values in the results.

Exercises 3 2. Enter the following and then click play. You should see the following in the results tab.

Exercises 3 List all Cities mentioned in the Customers table whose name starts with an r or an o. No duplicates are allowed in the results table.

Exercises 3 2. Enter the following and then click play. You should see the following in the results tab.