Introduction to SQL

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to SQL Introduction to SQL Phil Spector Introduction to SQL Phil Spector Statistical Computing Facility University of California, Berkeley Introduction to SQL I Structured Query Language I Usually “talk” to a database server I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Three Subsystems: data description, data access and privileges I Optimized for certain data arrangements I The language is case-sensitive, but I use upper case for keywords. Introduction to SQL What is SQL? I Usually “talk” to a database server I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Three Subsystems: data description, data access and privileges I Optimized for certain data arrangements I The language is case-sensitive, but I use upper case for keywords. Introduction to SQL What is SQL? I Structured Query Language I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Three Subsystems: data description, data access and privileges I Optimized for certain data arrangements I The language is case-sensitive, but I use upper case for keywords. Introduction to SQL What is SQL? I Structured Query Language I Usually “talk” to a database server I Three Subsystems: data description, data access and privileges I Optimized for certain data arrangements I The language is case-sensitive, but I use upper case for keywords. Introduction to SQL What is SQL? I Structured Query Language I Usually “talk” to a database server I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Optimized for certain data arrangements I The language is case-sensitive, but I use upper case for keywords. Introduction to SQL What is SQL? I Structured Query Language I Usually “talk” to a database server I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Three Subsystems: data description, data access and privileges I The language is case-sensitive, but I use upper case for keywords. Introduction to SQL What is SQL? I Structured Query Language I Usually “talk” to a database server I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Three Subsystems: data description, data access and privileges I Optimized for certain data arrangements Introduction to SQL What is SQL? I Structured Query Language I Usually “talk” to a database server I Used as front end to many databases (mysql, postgresql, oracle, sybase) I Three Subsystems: data description, data access and privileges I Optimized for certain data arrangements I The language is case-sensitive, but I use upper case for keywords. I Multiple simultaneous changes to data (concurrency) I Data changes on a regular basis I Large data sets where you only need some observations/variables I Share huge data set among many people I Rapid queries with no analysis I Web interfaces to data, especially dynamic data Introduction to SQL When do you need a Database? I Data changes on a regular basis I Large data sets where you only need some observations/variables I Share huge data set among many people I Rapid queries with no analysis I Web interfaces to data, especially dynamic data Introduction to SQL When do you need a Database? I Multiple simultaneous changes to data (concurrency) I Large data sets where you only need some observations/variables I Share huge data set among many people I Rapid queries with no analysis I Web interfaces to data, especially dynamic data Introduction to SQL When do you need a Database? I Multiple simultaneous changes to data (concurrency) I Data changes on a regular basis I Share huge data set among many people I Rapid queries with no analysis I Web interfaces to data, especially dynamic data Introduction to SQL When do you need a Database? I Multiple simultaneous changes to data (concurrency) I Data changes on a regular basis I Large data sets where you only need some observations/variables I Rapid queries with no analysis I Web interfaces to data, especially dynamic data Introduction to SQL When do you need a Database? I Multiple simultaneous changes to data (concurrency) I Data changes on a regular basis I Large data sets where you only need some observations/variables I Share huge data set among many people I Web interfaces to data, especially dynamic data Introduction to SQL When do you need a Database? I Multiple simultaneous changes to data (concurrency) I Data changes on a regular basis I Large data sets where you only need some observations/variables I Share huge data set among many people I Rapid queries with no analysis Introduction to SQL When do you need a Database? I Multiple simultaneous changes to data (concurrency) I Data changes on a regular basis I Large data sets where you only need some observations/variables I Share huge data set among many people I Rapid queries with no analysis I Web interfaces to data, especially dynamic data I Live Queries I Report Generation I Normalization, foreign keys, joins, etc. Newer uses: I Storage - data is extracted and analyzed in another application I Backends to web sites I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Report Generation I Normalization, foreign keys, joins, etc. Newer uses: I Storage - data is extracted and analyzed in another application I Backends to web sites I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Normalization, foreign keys, joins, etc. Newer uses: I Storage - data is extracted and analyzed in another application I Backends to web sites I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Report Generation Newer uses: I Storage - data is extracted and analyzed in another application I Backends to web sites I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Report Generation I Normalization, foreign keys, joins, etc. I Storage - data is extracted and analyzed in another application I Backends to web sites I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Report Generation I Normalization, foreign keys, joins, etc. Newer uses: I Backends to web sites I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Report Generation I Normalization, foreign keys, joins, etc. Newer uses: I Storage - data is extracted and analyzed in another application I Traditional rules may not be as important Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Report Generation I Normalization, foreign keys, joins, etc. Newer uses: I Storage - data is extracted and analyzed in another application I Backends to web sites Introduction to SQL Uses of Databases Traditional Uses: I Live Queries I Report Generation I Normalization, foreign keys, joins, etc. Newer uses: I Storage - data is extracted and analyzed in another application I Backends to web sites I Traditional rules may not be as important I console command (mysql -u user -p dbname) I GUI interfaces are often available I Interfaces to many programming languages: R, python, perl, PHP, etc. I SQLite - use SQL without a database server I PROC SQL in SAS Introduction to SQL Ways to Use SQL I GUI interfaces are often available I Interfaces to many programming languages: R, python, perl, PHP, etc. I SQLite - use SQL without a database server I PROC SQL in SAS Introduction to SQL Ways to Use SQL I console command (mysql -u user -p dbname) I Interfaces to many programming languages: R, python, perl, PHP, etc. I SQLite - use SQL without a database server I PROC SQL in SAS Introduction to SQL Ways to Use SQL I console command (mysql -u user -p dbname) I GUI interfaces are often available I SQLite - use SQL without a database server I PROC SQL in SAS Introduction to SQL Ways to Use SQL I console command (mysql -u user -p dbname) I GUI interfaces are often available I Interfaces to many programming languages: R, python, perl, PHP, etc. I PROC SQL in SAS Introduction to SQL Ways to Use SQL I console command (mysql -u user -p dbname) I GUI interfaces are often available I Interfaces to many programming languages: R, python, perl, PHP, etc. I SQLite - use SQL without a database server Introduction to SQL Ways to Use SQL I console command (mysql -u user -p dbname) I GUI interfaces are often available I Interfaces to many programming languages: R, python, perl, PHP, etc. I SQLite - use SQL without a database server I PROC SQL in SAS I A database server can contain many databases I Databases are collections of tables I Tables are two-dimensional with rows (observations) and columns (variables) I Limited mathematical and summary operations available I Very good at combining information from several tables Introduction to SQL Some Relational Database Concepts I Databases are collections of tables I Tables are two-dimensional with rows (observations) and columns (variables) I Limited mathematical and summary operations available I Very good at combining information from several tables Introduction to SQL Some Relational Database Concepts I A database server can contain many databases I Tables are two-dimensional with rows (observations) and columns (variables) I Limited mathematical and summary operations available I Very good at combining information from several tables Introduction to SQL Some Relational Database Concepts I A database server can contain many databases I Databases are collections
Recommended publications
  • Cobol/Cobol Database Interface.Htm Copyright © Tutorialspoint.Com
    CCOOBBOOLL -- DDAATTAABBAASSEE IINNTTEERRFFAACCEE http://www.tutorialspoint.com/cobol/cobol_database_interface.htm Copyright © tutorialspoint.com As of now, we have learnt the use of files in COBOL. Now, we will discuss how a COBOL program interacts with DB2. It involves the following terms: Embedded SQL DB2 Application Programming Host Variables SQLCA SQL Queries Cursors Embedded SQL Embedded SQL statements are used in COBOL programs to perform standard SQL operations. Embedded SQL statements are preprocessed by SQL processor before the application program is compiled. COBOL is known as the Host Language. COBOL-DB2 applications are those applications that include both COBOL and DB2. Embedded SQL statements work like normal SQL statements with some minor changes. For example, that output of a query is directed to a predefined set of variables which are referred as Host Variables. An additional INTO clause is placed in the SELECT statement. DB2 Application Programming Following are rules to be followed while coding a COBOL-DB2 program: All the SQL statements must be delimited between EXEC SQL and END-EXEC. SQL statements must be coded in Area B. All the tables that are used in a program must be declared in the Working-Storage Section. This is done by using the INCLUDE statement. All SQL statements other than INCLUDE and DECLARE TABLE must appear in the Procedure Division. Host Variables Host variables are used for receiving data from a table or inserting data in a table. Host variables must be declared for all values that are to be passed between the program and the DB2. They are declared in the Working-Storage Section.
    [Show full text]
  • An Array-Oriented Language with Static Rank Polymorphism
    An array-oriented language with static rank polymorphism Justin Slepak, Olin Shivers, and Panagiotis Manolios Northeastern University fjrslepak,shivers,[email protected] Abstract. The array-computational model pioneered by Iverson's lan- guages APL and J offers a simple and expressive solution to the \von Neumann bottleneck." It includes a form of rank, or dimensional, poly- morphism, which renders much of a program's control structure im- plicit by lifting base operators to higher-dimensional array structures. We present the first formal semantics for this model, along with the first static type system that captures the full power of the core language. The formal dynamic semantics of our core language, Remora, illuminates several of the murkier corners of the model. This allows us to resolve some of the model's ad hoc elements in more general, regular ways. Among these, we can generalise the model from SIMD to MIMD computations, by extending the semantics to permit functions to be lifted to higher- dimensional arrays in the same way as their arguments. Our static semantics, a dependent type system of carefully restricted power, is capable of describing array computations whose dimensions cannot be determined statically. The type-checking problem is decidable and the type system is accompanied by the usual soundness theorems. Our type system's principal contribution is that it serves to extract the implicit control structure that provides so much of the language's expres- sive power, making this structure explicitly apparent at compile time. 1 The Promise of Rank Polymorphism Behind every interesting programming language is an interesting model of com- putation.
    [Show full text]
  • 2020-2021 Course Catalog
    Unlimited Opportunities • Career Training/Continuing Education – Page 4 • Personal Enrichment – Page 28 • High School Equivalency – Page 42 • Other Services – Page 46 • Life Long Learning I found the tools and resources to help me transition from my current career to construction management through an Eastern Suffolk BOCES Adult Education Blueprint Reading course. The program provided networking opportunities which led me to my new job. 2020-2021 COURSE CATALOG SHARE THIS CATALOG with friends and family Register online at: www.esboces.org/AEV Adult Education Did You Know... • Adult Education offers over 50 Career Training, Licensing and Certification programs and 30 Personal Enrichment classes. • Financial aid is available for our Cosmetology and Practical Nursing programs. • We offer national certifications for Electric, Plumbing and HVAC through the National Center for Construction Education and Research. • Labor Specialists and Vocational Advisors are available to assist students with planning their careers, registration and arranging day and evening tours. • Continuing Education classes are available through our on-line partners. The Center for Legal Studies offers 15 classes designed for beginners as well as advanced legal workers. In addition, they provide 6 test preparation courses including SAT®, GMAT® and LSAT®. UGotClass offers over 40 classes in Business, Management, Education and more. • Internship opportunities are available in many of our classes to assist the students to build skills towards employment. Do you know what our students are saying about us? “New York State “Great teacher. Answered Process Server is all questions and taught a very lucrative “I like how the Certified Microsoft Excel in a way “I took Introduction to side business.
    [Show full text]
  • Heritage Ascential Software Portfolio, Now Available in Passport Advantage, Delivers Trustable Information for Enterprise Initiatives
    Software Announcement July 18, 2006 Heritage Ascential software portfolio, now available in Passport Advantage, delivers trustable information for enterprise initiatives Overview structures ranging from simple to highly complex. It manages data At a glance With the 2005 acquisition of arriving in real time as well as data Ascential Software Corporation, received on a periodic or scheduled IBM software products acquired IBM added a suite of offerings to its basis and enables companies to from Ascential Software information management software solve large-scale business problems Corporation are now available portfolio that helps you profile, through high-performance through IBM Passport Advantage cleanse, and transform any data processing of massive data volumes. under new program numbers and across the enterprise in support of A WebSphere DataStage Enterprise a new, simplified licensing model. strategic business initiatives such as Edition license grants entitlement to You can now license the following business intelligence, master data media for both WebSphere programs for distributed platforms: DataStage Server and WebSphere management, infrastructure • consolidation, and data governance. DataStage Enterprise Edition. Core product: WebSphere The heritage Ascential programs in Datastore Enterprise Edition, this announcement are now WebSphere RTI enables WebSphere WebSphere QualityStage available through Passport DataStage jobs to participate in a Enterprise Edition, WebSphere Advantage under a new, service-oriented architecture (SOA)
    [Show full text]
  • The History and Development of Jazz Piano : a New Perspective for Educators
    University of Massachusetts Amherst ScholarWorks@UMass Amherst Doctoral Dissertations 1896 - February 2014 1-1-1975 The history and development of jazz piano : a new perspective for educators. Billy Taylor University of Massachusetts Amherst Follow this and additional works at: https://scholarworks.umass.edu/dissertations_1 Recommended Citation Taylor, Billy, "The history and development of jazz piano : a new perspective for educators." (1975). Doctoral Dissertations 1896 - February 2014. 3017. https://scholarworks.umass.edu/dissertations_1/3017 This Open Access Dissertation is brought to you for free and open access by ScholarWorks@UMass Amherst. It has been accepted for inclusion in Doctoral Dissertations 1896 - February 2014 by an authorized administrator of ScholarWorks@UMass Amherst. For more information, please contact [email protected]. / DATE DUE .1111 i UNIVERSITY OF MASSACHUSETTS LIBRARY LD 3234 ^/'267 1975 T247 THE HISTORY AND DEVELOPMENT OF JAZZ PIANO A NEW PERSPECTIVE FOR EDUCATORS A Dissertation Presented By William E. Taylor Submitted to the Graduate School of the University of Massachusetts in partial fulfil Iment of the requirements for the degree DOCTOR OF EDUCATION August 1975 Education in the Arts and Humanities (c) wnii aJ' THE HISTORY AND DEVELOPMENT OF JAZZ PIANO: A NEW PERSPECTIVE FOR EDUCATORS A Dissertation By William E. Taylor Approved as to style and content by: Dr. Mary H. Beaven, Chairperson of Committee Dr, Frederick Till is. Member Dr. Roland Wiggins, Member Dr. Louis Fischer, Acting Dean School of Education August 1975 . ABSTRACT OF DISSERTATION THE HISTORY AND DEVELOPMENT OF JAZZ PIANO; A NEW PERSPECTIVE FOR EDUCATORS (AUGUST 1975) William E. Taylor, B.S. Virginia State College Directed by: Dr.
    [Show full text]
  • Data Definition Language
    1 Structured Query Language SQL, or Structured Query Language is the most popular declarative language used to work with Relational Databases. Originally developed at IBM, it has been subsequently standard- ized by various standards bodies (ANSI, ISO), and extended by various corporations adding their own features (T-SQL, PL/SQL, etc.). There are two primary parts to SQL: The DDL and DML (& DCL). 2 DDL - Data Definition Language DDL is a standard subset of SQL that is used to define tables (database structure), and other metadata related things. The few basic commands include: CREATE DATABASE, CREATE TABLE, DROP TABLE, and ALTER TABLE. There are many other statements, but those are the ones most commonly used. 2.1 CREATE DATABASE Many database servers allow for the presence of many databases1. In order to create a database, a relatively standard command ‘CREATE DATABASE’ is used. The general format of the command is: CREATE DATABASE <database-name> ; The name can be pretty much anything; usually it shouldn’t have spaces (or those spaces have to be properly escaped). Some databases allow hyphens, and/or underscores in the name. The name is usually limited in size (some databases limit the name to 8 characters, others to 32—in other words, it depends on what database you use). 2.2 DROP DATABASE Just like there is a ‘create database’ there is also a ‘drop database’, which simply removes the database. Note that it doesn’t ask you for confirmation, and once you remove a database, it is gone forever2. DROP DATABASE <database-name> ; 2.3 CREATE TABLE Probably the most common DDL statement is ‘CREATE TABLE’.
    [Show full text]
  • SQL Vs Nosql: a Performance Comparison
    SQL vs NoSQL: A Performance Comparison Ruihan Wang Zongyan Yang University of Rochester University of Rochester [email protected] [email protected] Abstract 2. ACID Properties and CAP Theorem We always hear some statements like ‘SQL is outdated’, 2.1. ACID Properties ‘This is the world of NoSQL’, ‘SQL is still used a lot by We need to refer the ACID properties[12]: most of companies.’ Which one is accurate? Has NoSQL completely replace SQL? Or is NoSQL just a hype? SQL Atomicity (Structured Query Language) is a standard query language A transaction is an atomic unit of processing; it should for relational database management system. The most popu- either be performed in its entirety or not performed at lar types of RDBMS(Relational Database Management Sys- all. tems) like Oracle, MySQL, SQL Server, uses SQL as their Consistency preservation standard database query language.[3] NoSQL means Not A transaction should be consistency preserving, meaning Only SQL, which is a collection of non-relational data stor- that if it is completely executed from beginning to end age systems. The important character of NoSQL is that it re- without interference from other transactions, it should laxes one or more of the ACID properties for a better perfor- take the database from one consistent state to another. mance in desired fields. Some of the NOSQL databases most Isolation companies using are Cassandra, CouchDB, Hadoop Hbase, A transaction should appear as though it is being exe- MongoDB. In this paper, we’ll outline the general differences cuted in iso- lation from other transactions, even though between the SQL and NoSQL, discuss if Relational Database many transactions are execut- ing concurrently.
    [Show full text]
  • SQL Server Express: Setting up for Unistream User Guide 3/17
    Headquarters Unitronics (1989) (R"G). Unitronics Building, Airport City P.O.B. 300, Ben Gurion Airport, Israel 70100 Tel: + 972 (3) 977 8888 Fax: + 972 (3) 977 8877 SQL Server Express: Setting up for UniStream User Guide 3/17 Contents SQL Server Express: Setting up for UniStream ...................................................... 1 Overview ....................................................................................................... 1 Supported Controllers ...................................................................................... 1 First-time Installation & Configuration ................................................................. 2 Download ...................................................................................................... 2 Installing SQL Server ...................................................................................... 3 Setting up the Local Database .......................................................................... 5 Configuring SQL Server ................................................................................... 6 Activating the SQL Server Browser. ................................................................ 6 Enable TCP/IP, Assign Port ............................................................................ 7 Create a new Login ....................................................................................... 8 SQL Server Express—Existing Installation ........................................................... 10 Enable TCP/IP, Assign Port
    [Show full text]
  • Cohesity Dataplatform Protecting Individual MS SQL Databases Solution Guide
    Cohesity DataPlatform Protecting Individual MS SQL Databases Solution Guide Abstract This solution guide outlines the workflow for creating backups with Microsoft SQL Server databases and Cohesity Data Platform. Table of Contents About this Guide..................................................................................................................................................................2 Intended Audience..............................................................................................................................................2 Configuration Overview.....................................................................................................................................................2 Feature Overview.................................................................................................................................................................2 Installing Cohesity Windows Agent..............................................................................................................................2 Downloading Cohesity Agent.........................................................................................................................2 Select Coheisty Windows Agent Type.........................................................................................................3 Install the Cohesity Agent.................................................................................................................................3 Cohesity Agent Setup........................................................................................................................................4
    [Show full text]
  • Applying the ETL Process to Blockchain Data. Prospect and Findings
    information Article Applying the ETL Process to Blockchain Data. Prospect and Findings Roberta Galici 1, Laura Ordile 1, Michele Marchesi 1 , Andrea Pinna 2,* and Roberto Tonelli 1 1 Department of Mathematics and Computer Science, University of Cagliari, Via Ospedale 72, 09124 Cagliari, Italy; [email protected] (R.G.); [email protected] (L.O.); [email protected] (M.M.); [email protected] (R.T.) 2 Department of Electrical and Electronic Engineering (DIEE), University of Cagliari, Piazza D’Armi, 09100 Cagliari, Italy * Correspondence: [email protected] Received: 7 March 2020; Accepted: 7 April 2020; Published: 10 April 2020 Abstract: We present a novel strategy, based on the Extract, Transform and Load (ETL) process, to collect data from a blockchain, elaborate and make it available for further analysis. The study aims to satisfy the need for increasingly efficient data extraction strategies and effective representation methods for blockchain data. For this reason, we conceived a system to make scalable the process of blockchain data extraction and clustering, and to provide a SQL database which preserves the distinction between transaction and addresses. The proposed system satisfies the need to cluster addresses in entities, and the need to store the extracted data in a conventional database, making possible the data analysis by querying the database. In general, ETL processes allow the automation of the operation of data selection, data collection and data conditioning from a data warehouse, and produce output data in the best format for subsequent processing or for business. We focus on the Bitcoin blockchain transactions, which we organized in a relational database to distinguish between the input section and the output section of each transaction.
    [Show full text]
  • Developing Embedded SQL Applications
    IBM DB2 10.1 for Linux, UNIX, and Windows Developing Embedded SQL Applications SC27-3874-00 IBM DB2 10.1 for Linux, UNIX, and Windows Developing Embedded SQL Applications SC27-3874-00 Note Before using this information and the product it supports, read the general information under Appendix B, “Notices,” on page 209. Edition Notice This document contains proprietary information of IBM. It is provided under a license agreement and is protected by copyright law. The information contained in this publication does not include any product warranties, and any statements provided in this manual should not be interpreted as such. You can order IBM publications online or through your local IBM representative. v To order publications online, go to the IBM Publications Center at http://www.ibm.com/shop/publications/ order v To find your local IBM representative, go to the IBM Directory of Worldwide Contacts at http://www.ibm.com/ planetwide/ To order DB2 publications from DB2 Marketing and Sales in the United States or Canada, call 1-800-IBM-4YOU (426-4968). When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright IBM Corporation 1993, 2012. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Chapter 1. Introduction to embedded Include files for COBOL embedded SQL SQL................1 applications .............29 Embedding SQL statements
    [Show full text]
  • The Temporal Query Language Tquel
    The Temporal Query Language TQuel RICHARD SNODGRASS University of North Carolina Recently, attention has been focused on temporal datubases, representing an enterprise over time. We have developed a new language, TQuel, to query a temporal database. TQuel was designed to be a minimal extension, both syntactically and semantically, of Quel, the query language in the Ingres relational database management system. This paper discusses the language informally, then provides a tuple relational calculus semantics for the TQuel statements that differ from their Quel counterparts, including the modification statements. The three additional temporal constructs defined in TQuel are shown to be direct semantic analogues of Quel’s where clause and target list. We also discuss reducibility of the semantics to Quel’s semantics when applied to a static database. TQuel is compared with ten other query languages supporting time. Categories and Subject Descriptors: H.2.1 [Database Management]: Logical Design-data models; H.2.3 [Database Management]: Languages-query lunguages; H.2.7 [Database Management]: Database Administration-logging and recovery General Terms: Languages, Theory Additional Key Words and Phrases: Historical database, Quel, relational calculus, relational model, rollback database, temporal database, tuple calculus 1. INTRODUCTION Most conventional databases represent the state of an enterprise at a single moment of time. Although the contents of the database continue to change as new information is added, these changes are viewed as modifications to the state, with the old, out-of-date data being deleted from the database. The current contents of the database may be viewed as a snapshot of the enterprise. Recently, attention has been focused on temporal dutubases (Z’DBs), repre- senting the progression of states of an enterprise over an interval of time.
    [Show full text]