CS122 Using Relational Databases and SQL Huiping Guo Department of Computer Science California State University, Los Angeles 1. Introduction.

Slides:



Advertisements
Similar presentations
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Advertisements

Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
1 IS380 Class Agenda 01/11/05 Sock H. Chung 1.Syllabus 2.Chapter 1 3.Introduction 4. Request.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 1: Introduction to Relational.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Laboratory 1: Introduction to Relational.
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.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 2: Single-Table Selections.
CSC 2720 Building Web Applications Database and SQL.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
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
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 8 SQL-99: Schema Definition, Constraints, and Queries and Views.
Chapter 9 Database Management Discovering Computers Fundamental.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
SQL Queries Relational database and SQL MySQL LAMP SQL queries A MySQL Tutorial and applications Database Building Assignment.
1 Working with MS SQL Server Textbook Chapter 14.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 2720 Building Web Applications Database and SQL.
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.
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
INFS614, Dr. Brodsky, GMU1 Database Management Systems INFS 614 Instructor: Professor Alex Brodsky
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
Concepts of Database Management Seventh Edition
Chapter 5 Database Processing. Neil uses software to query a database, but it has about 25 standard queries that don’t give him all he needs. He imports.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
COP3502: Introduction to Computer Science Yashas Shankar.
CS 3630 Database Design and Implementation. Assignment 3 Style! Agreement between database designer and the client. UserName1_EasyDrive UserName2_EasyDrive.
Relational Database. Database Management System (DBMS)
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
DATABASE TOOLS CS 260 Database Systems. Overview  Database accounts  Oracle SQL Developer  MySQL Workbench.
Introduction to Database Management Systems. Information Instructor: Csilla Farkas Office: Swearingen 3A43 Office Hours: Monday, Wednesday 2:30 pm – 3:30.
DAY 16: ACCESS CHAPTER 1-2 Rahul Kavi October 8,
IST 210: Organization of Data
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
Course Info Instructor U.T. Nguyen Office: CSEB Office hours: Tuesday, 14:30-15:30 Thursday, 12:00-12:45 By.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
IST 210: ORGANIZATION OF DATA Introduction IST210 1.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
CSCI-235 Micro-Computers in Science Databases. Database Concepts Data is any unorganized text, graphics, sounds, or videos A database is a collection.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
CS522 Advanced database Systems Huiping Guo Department of Computer Science California State University, Los Angeles Course administration.
CS320 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
Chapter 8 Working with Databases and MySQL
CS1222 Using Relational Databases and SQL
Structured Query Language
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
Presentation transcript:

CS122 Using Relational Databases and SQL Huiping Guo Department of Computer Science California State University, Los Angeles 1. Introduction

1. Introduction CS122_W Course administration r Lectures m Lec: Monday 4:20 – 6:00pm, ET A210 m Lab: Wednesday 3:30 – 6:00pm, ET A210 r Instructor: Huiping Guo m m Phone: (323) m Office: ET-A318 m Office hours: M: 10: :00 PM W: 10:30 – 12:30 r Course webpage m CS122/CS122_W16.htm CS122/CS122_W16.htm

1. Introduction CS122_W Course administration (Cont.) r Textbook  “SQL Essentials” by Gary Randolph and Jeffrey Griffin Franklin Beedle & Associates, r Resources m SQL Tutorial m MySQL Tutorial Lynda

1. Introduction CS122_W Course administration (Cont.) r Grading policy m Homework (individual): (20%) m Lab(group): (15%) m In-class project(group): (10%) m Attendance (5%) m Midterm (20%): 02/10 m Final exam (30%): Monday, 03/14, 4:30 – 7:00pm r Group up! m Form groups of 2 students m me the name of your group partner ASAP! (one /group) m Put CS122 group in the subject line r Final letter grade m A A m B B m C NC < 60

Note: r The grading policy is for all students in the class r No extra homework r No make up exams m DO NOT take this class if you cannot attend the final exam!  You ’ ll be graded based ONLY on your performance! m NOT on your request 1. Introduction CS122_W16 1-5

Course administration (Cont.) r Note: m Assignment and lab submissions: Through CSNS Make sure your files are READABLE! Please submit your homework/lab before the due time The submission button will be disabled after the due time  I don ’ t accept submissions! 1. Introduction CS122_W16 1-6

1. Introduction CS122_W Course administration (Cont.) r CSNS webpage m m Every student enrolled in the class has an account m both of your username and password are your CIN. m When you first sign in, you will be asked to choose a different username and password. m If you already used the system in other classes, your username and password are the same as before. r Make sure you give the correct address

1. Introduction CS122_W Course administration (Cont.) r CSNS: how to modify the uploaded file m You cannot delete the uploaded file m Modify the file and upload it with the same name + a version number to CSNS r How to know your grade m You’ll receive an if your address in CSNS is correct m Log into CSNS to check

Course administration (Cont.) r Important dates m Thursday, Feb 18 Drop Deadline r Academic integrity m DON’T COPY OTHER’S WORK! m DON’T GIVE YOUR SOLUTIONS TO ANYONE! m If plagiarism is found, ALL parties involved will get F 1. Introduction CS122_W16 1-9

Other policies r DO NOT talk in class during lectures r After lecture, leave the classroom m Students are not allowed to stay in the classroom alone without the presence of the instructor r Please turn off your cell phone! 1. Introduction CS122_W

New teaching strategies r Course Redesign With Technology m Funded by the Chancellor’s Office r The class will be partially flipped m Some lectures will be recorded and the videos will be put on the class website m You’re SUPPOSDED to watch the video before attending the class m You need to work on some projects in class r Please take this survey m se/edit?surveyId= se/edit?surveyId= Introduction CS122_W

Introduction

1. Introduction CS122_W What is a database? r A large, integrated collection of data m Bank m Company m E-commerce m Government m University m ……….

1. Introduction CS122_W Why use a database? r Efficient data management access r Concurrent access and crash recovery r Data integrity and security r Data administration r Data independence r Reduced application development time

1. Introduction CS122_W Database models r Physical model m How data is stored on a disk r Logical model m How data is organized m Three models Hierarchical Network Relational

1. Introduction CS122_W Relational model r Most popular relational DBMS m Oracle, Sybase, MySQL, SQL Server, Access m In this model, a database is a collection of tables m The tables are related to each other

1. Introduction CS122_W Field (column, Attribute) Record (tuple, row) Relational Database Concepts: Table Table (Relation) Table: Titles

1. Introduction CS122_W Relational Database Concepts r Candidate Key m Also called keys m Uniquely identify a record No two rows have the same candidate key m Maybe multiple candidate keys in a table r Primary key m Select a candidate key as the primary key m Only one primary key in a table

1. Introduction CS122_W Relational Database Concepts r Candidate keys m titleID, Title, UPC r Primary key m Any ONE of the candidate keys

1. Introduction CS122_W Data type r Determine what kind of data a field can store r Common data types m Text m Numeric Byte integer, long integer, single, double, decimal date/time, boolean Special

1. Introduction CS122_W Schema r “Definition” of a database m Names of the tables m Attributes and attribute types in each table m Constraints on each tables m Dependencies between tables r To be covered in CS422

1. Introduction CS122_W Introduction to SQL r Structured Query Language r Open ANSI standard m Supported by most databases m Some variation in implementation r A skill that is used by many people in many environments m Programmers m Database Administrators m Managers

1. Introduction CS122_W What Does SQL Do? r Views information from relational database m Single or Multiple Tables m Tools to Calculate and Summarize r Manipulates information in relational database m Insert Records m Update Records m Delete Records m Operates on entire recordset with single command r Defines relational database m Create Database, Tables, Primary and Foreign Keys

1. Introduction CS122_W SQL queries r Basic format: SELECT filed_name1, field_name2,… FROM table_name1, tabel_name2… [WHERE conditions ] r If you select ALL attributes of a table SELECT * FROM table_name [WHERE conditions]

1. Introduction CS122_W SQL examples r List all the attributes of all titles SECLECT * FROM Titles r List the title and upc of all titles SECLECT title, upc FROM Titles r List the title and upc of the titles in the ‘metal’ genre SECLECT title, upc FROM Titles WHERE genre = ‘metal’

Using MySQL

1. Introduction CS122_W Introduction to MySQL r MySQL is a free client-server DBMS r MySQL Sever m cs1.calstatela.edu r MySQL client m Graphical User Interface tool MySQL Workbench, MYSQL client… m Command line Connect to the server directly under the command window We’ll use SSH Secure Shell ClientSSH Secure Shell Client

1. Introduction CS122_W Use MySQL on the CS server 1. Log into the CS server using SSH 2. Connect to the MySQL server 3. Play with MySQL

1. Introduction CS122_W Log into the cs sever r Use SSH to log in m Launch SSH Secure Shell Client m Click Quick Connect m Type the following info Host name: cs1.calstatela.edu User name: your assigned user id you’ll be asked to input password –Password is case sensitive

1. Introduction CS122_W Log into the cs sever r After logging in, change your password m The password is for the cs server! m You need to input the current password m The password you typed won’t show up!

1. Introduction CS122_W Connect to the MySQL server r $mysql –p m You will be asked to input the password. m The password is the original password assigned to you, not the password you just changed to. m The password you type DOESN’T show up

1. Introduction CS122_W Connect to the MySQL server r Change your password mysql> SET PASSWORD = PASSWORD (‘ your new password'); Note:You had better set the same password for the CS server and the MySQL server

1. Introduction CS122_W Choose the database r Each student has only one database m The name of the database is the same as your username r You don’t have the privilege to create new databases r The database doesn’t contain any tables

1. Introduction CS122_W Choose the database r After connected to MySQL sever, you need to choose the database m Mysql> Use database_name;

1. Introduction CS122_W Transfer the script files to the server r You’ll use two script files m Lyric.sql: for your labs and in-class projects m Books.sql: for your homework m The two files are used to create tables in your database m You need to transfer the two files to the cs server before using the files to create the tables

1. Introduction CS122_W Transfer the script files to the server (Cont.) r How? 1. Go to the course web page mFind the two files: Lyric.sql, Books.sql mRight click a file, chose “Save Links As” mChoose any folder you want folder, say c:\temp mYou need to memorize the folder name

1. Introduction CS122_W Transfer the script files to the server (Cont.) 2. Launch SSH Secure File Transfer Client click

1. Introduction CS122_W Transfer the script files to the server (Cont.) 3. On the top-left window, choose the folder where the two files are

1. Introduction CS122_W Transfer the script files to the server (Cont.) 4. Drag files to the top-right window

1. Introduction CS122_W Run script files r Go back to the secure shell client window r Command m mysql>use hpguo; m mysql> source lyric.sql;

Run script files r To do assignments r Use the same database r Run Books.sql r All tables in Lyric will be removed. r You need to run lyric.sql again to do labs or in-class projects. 1. Introduction CS122_W

1. Introduction CS122_W Some MySQL commands r Help m ? or \h or help; r Reconnect to the server m Connect; r Display sever info m Status r Quite MySQL m \q or quit; or exit;

1. Introduction CS122_W Some MySQL commands r Show databases m Show databases; r use database m Use dbname; r Show tables m Show tables; r Show table schema m Desc tablename;

1. Introduction CS122_W Exercise r Design the following queries: 1. Find all the information of sales person 2. Find the name and web address of all artists 3. Find the names of all artists who are in Canada