CS4540 Special Topics in Web Development SQL and MS SQL

Slides:



Advertisements
Similar presentations
Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
Advertisements

Database Design -- Basic SQL
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
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.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
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.
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.
Relational Database CISC/QCSE 810 some materials from Software Carpentry.
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.
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.
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.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
What’s a database? Data stored in a structured format that lends itself to easy manipulation and recall.
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 Basics BCIS 3680 Enterprise Programming.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
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.
Databases and SQL CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
 CONACT UC:  Magnific training   
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
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.
Introduction to Database Programming with Python Gary Stewart
 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.
Web Database Programming Using PHP
Chengyu Sun California State University, Los Angeles
Web Systems & Technologies
CS 3630 Database Design and Implementation
CS3220 Web and Internet Programming More SQL
CS320 Web and Internet Programming SQL and MySQL
CS422 Principles of Database Systems Course Overview
Web Database Programming Using PHP
Data Definition and Data Types
Principles of Software Development
Using SQL Server through Command Prompt
CS1222 Using Relational Databases and SQL
ORACLE SQL Developer & SQLPLUS Statements
ISC440: Web Programming 2 Server-side Scripting PHP 3
Relational Databases The Relational Model.
Relational Databases The Relational Model.
CS1222 Using Relational Databases and SQL
SQL OVERVIEW DEFINING A SCHEMA
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Defining a Database Schema
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Chengyu Sun California State University, Los Angeles
Contents Preface I Introduction Lesson Objectives I-2
CS1222 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS3220 Web and Internet Programming SQL and MySQL
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
CS1222 Using Relational Databases and SQL
CS4540 Special Topics in Web Development LINQ to Objects
CS1222 Using Relational Databases and SQL
Navigating SSMS Primer for Beginners
Presentation transcript:

CS4540 Special Topics in Web Development SQL and MS SQL Chengyu Sun California State University, Los Angeles

A Relational DB Example Employees EmployeeId FirstName LastName DateHired SupervisorId 1 John Doe 2015-01-10 null 2 Jane 2015-02-20 Projects ProjectMembers ProjectId Name LeaderId 1 Firestone 2 Blue ProjectId EmployeeId 1 2

Terminology DBMS DB DB DB Database Schema Schema Schema Tables (relations) Views, indexes Procedures and triggers … Schema Schema Schema Database

DBMS Database Management System (DBMS) is a software that manages databases Common DBMS Commercial – Oracle, IBM DB2, MS SQL Server, Access Open source – MySQL, PostgreSQL

Database and Schema A database is a collection of data managed by a DBMS Many DBMS also support sub-collections within a database called schemas The default schema in MS SQL Server is dbo (stands for database owner) Tables, indexes, stored procedures … are often called database objects or schema elements

More Terminology Table (relation) Attributes (fields, columns) StudentId Name 1001 John Doe 1002 Jane Doe Rows (Records) (Tuples) Students Table schema: Students( StudentId, Name ) Database schema: database name + table schemas

Client-Server Architecture SSMS Azure Data Studio sqlcmd Applications … SQL Server DB DB DB

Connect to a Database Use one of the client software Connection information Host Port (default 1433) Username Password Database/Schema See Using MS SQL Server on ECST-CSPROJ2

SQL Structured Query Language Standard query language of relational databases Supported by all major relational databases with some variations Transact-SQL (T-SQL) for MS SQL Server

Create Tables Coding conventions Data types and literals SQL script

Coding Conventions Plural form for table names, and singular form for column names PascalCasing for names, and capitalize SQL keywords Use [] around names in case they contains special characters

Common Data Types Numeric String Date and time bit, int, smallint, bigint real, float(n) String char(n), varchar(n) nchar(n), nvarchar(n) for Unicode Date and time date, time, datetime, datetime2

About IDENTITY Similar to AUTO_INCREMENT in MySQL Can be customized with seed and increment, e.g. IDENITY(1000,1) Must set IDENTITY_INSERT to ON before inserting an explicit value to an identity column

SQL Literals Called Constants in MS documentation Unicode strings are prefixed with N Default date format is 'YYYY-MM-dd'

SQL Script A text file contains SQL statements and comments Usually uses .sql suffix Use sqlcmd -i <script> to run script on command line When using sqlcmd, the GO command sends the preceding statements to SQL server to execute as a batch

Simple Selections Example: find the employees whose last names are Doe

Using Functions T-SQL Functions Example: find the names of the employees who were hired in 2015

Join Example: find the name of the leader of the project Blue Equi-join Inner join

Aggregation Example: list the name and the number of employees for each project

Other Statements Change password ALTER LOGIN <username> WITH PASSWORD = '<new_password>' OLD_PASSWORD = '<old_password>'

References Transact-SQL (T-SQL) Reference