CS1222 Using Relational Databases and SQL

Slides:



Advertisements
Similar presentations
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.
Advertisements

Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 1: Introduction to Relational.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
CSC 2720 Building Web Applications Database and SQL.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Database Lecture # 1 By Ubaid Ullah.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
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.
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
Chapter 4 Introduction to MySQL. MySQL “the world’s most popular open-source database application” “commonly used with PHP”
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Component 4: Introduction to Information and Computer Science Unit 6a Databases and SQL.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
CS453: Databases and State in Web Applications (Part 2) Prof. Tom Horton.
Introduction to Database Management System 電機三 趙上鋒.
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.
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.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
Introduction to Database Programming with Python Gary Stewart
CS122 Using Relational Databases and SQL Huiping Guo Department of Computer Science California State University, Los Angeles 1. Introduction.
Fundamental of Database Systems
DBM 380 AID Focus Dreams/dbm380aid.com
INTRODUCTION TO DATABASES (MICROSOFT ACCESS)
CS 3630 Database Design and Implementation
CS320 Web and Internet Programming SQL and MySQL
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
CS422 Principles of Database Systems Course Overview
Fundamentals & Ethics of Information Systems IS 201
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
Web Programming Week 3 Old Dominion University
Chapter 4 Relational Databases
CS1222 Using Relational Databases and SQL
Database Management  .
Databases and Information Management
ORACLE SQL Developer & SQLPLUS Statements
Database Basics An Overview.
Chapter 8 Working with Databases and MySQL
Chapter 6 System and Application Software
Database.
CS1222 Using Relational Databases and SQL
Structured Query Language
CS122 Using Relational Databases and SQL
Accounting Information Systems 9th Edition
Web Programming Week 3 Old Dominion University
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
Chapter 4 Introduction to MySQL.
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
Chapter 6 System and Application Software
CS3220 Web and Internet Programming SQL and MySQL
Chapter 6 System and Application Software
CS1222 Using Relational Databases and SQL
DATABASE Purpose of database
CS122 Using Relational Databases and SQL
Chapter 6 System and Application Software
Web Programming Week 3 Old Dominion University
CS122 Using Relational Databases and SQL
Database Instructor: Bei Kang.
CS4540 Special Topics in Web Development SQL and MS SQL
CS1222 Using Relational Databases and SQL
Presentation transcript:

CS1222 Using Relational Databases and SQL 4/5/2019 CS1222 Using Relational Databases and SQL 1. Introduction Yuqing Zhu Slides prepared by Randy Moss Department of Computer Science California State University, Los Angeles

4/5/2019 Introduction

What is a database? A large, integrated collection of data Bank 4/5/2019 What is a database? A large, integrated collection of data Bank Company E-commerce Government University ………. 1. Introduction CS1222-Fall2017

Why use a database? Efficient data management access 4/5/2019 Why use a database? Efficient data management access Concurrent access and crash recovery Data administration Data integrity and security Data independence Reduced application development time 1. Introduction CS1222-Fall2017

Database models Physical model Logical model 4/5/2019 Database models Physical model How data is stored on a disk Logical model How data is organized Examples NoSQL Key-value pair Relational A set of concepts to describe the structure of a database, and certain constraints that the database should obey. 1. Introduction CS1222-Fall2017

Relational model Most popular relational DBMS 4/5/2019 Relational model Most popular relational DBMS Oracle, Postgres, MySQL, SQL Server, Access, and more How do Relational DBs store data? Tables! 1. Introduction CS1222-Fall2017

Relational Database Concepts: Table 4/5/2019 Relational Database Concepts: Table Field (column, Attribute) Table (Relation) Table: Titles Record (tuple, row) 1. Introduction CS1222-Fall2017

Relational Database Concepts 4/5/2019 Relational Database Concepts Candidate Key Uniquely identify a record No two rows have the same candidate key Maybe multiple candidate keys in a table Primary key Select a candidate key as the primary key Only one primary key in a table 1. Introduction CS1222-Fall2017

Relational Database Concepts 4/5/2019 Relational Database Concepts Candidate keys titleID, Title, UPC Primary key Any ONE of the candidate keys 1. Introduction CS1222-Fall2017

Data type Determine what kind of data a field can store 4/5/2019 Data type Determine what kind of data a field can store Common data types Text Numeric Byte integer, long integer, single, double, decimal date/time, boolean Special 1. Introduction CS1222-Fall2017

Schema “Definition” of a database Names of the tables 4/5/2019 Schema “Definition” of a database Names of the tables Attributes and attribute types in each table Constraints on each tables Dependencies between tables 1. Introduction CS1222-Fall2017

Introduction to SQL Structured Query Language Open ANSI standard 4/5/2019 Introduction to SQL Structured Query Language Open ANSI standard Supported by most databases Some variation in implementation A skill that is used by many people in many environments Programmers Database Administrators Managers 1. Introduction CS1222-Fall2017

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

SQL queries Basic format: If you select ALL attributes of a table 4/5/2019 SQL queries Basic format: SELECT filed_name1, field_name2,… FROM table_name1, tabel_name2… [WHERE conditions] If you select ALL attributes of a table SELECT * FROM table_name [WHERE conditions] 1. Introduction CS1222-Fall2017

SQL examples List all the attributes of all titles 4/5/2019 SQL examples List all the attributes of all titles SELECT * FROM Titles List the title and upc of all titles SELECT title, upc List the title and upc of the titles in the ‘metal’ genre WHERE genre = ‘metal’ 1. Introduction CS1222-Fall2017

4/5/2019 Using MySQL

2. Connect to the MySQL server 4/5/2019 2. Connect to the MySQL server $mysql –p You will be asked to input the password. The password is the original password assigned to you, not the password you just changed to. Change your password mysql> set password=PASSWORD(“new password”); $mysql –u username –p 1. Introduction CS1222-Fall2017

Run script files You’ll use four script files 4/5/2019 Run script files You’ll use four script files Lyric.sql: mostly for your labs Books.sql: mostly for your homework Orders.sql and Sailors.sql: mostly for exams These four files are used to create tables in your database 1. Introduction CS1222-Fall2017

Some MySQL commands Help Reconnect to the server Display sever info 4/5/2019 Some MySQL commands Help ? or \h or help; Reconnect to the server Connect; Display sever info Status Quit MySQL \q or quit; or exit; 1. Introduction CS1222-Fall2017

Some MySQL commands Show databases use database Show tables 4/5/2019 Some MySQL commands Show databases Show databases; use database Use dbname; Show tables Show tables; Show table schema Desc tablename 1. Introduction CS1222-Fall2017