The document discusses null values in SQL and how they complicate issues like comparisons and logical operations. It also covers different types of joins in SQL like inner joins, left outer joins, right outer joins, and full outer joins. Finally, it provides an overview of how SQL statements can be embedded in other programming languages using APIs like JDBC which allows SQL to be executed from within Java programs.
Farheen abdul hameed ip project (MY SQL);abdul talha
The document provides information on various SQL commands and functions for creating and managing databases and tables, inserting and retrieving data, and performing queries. It includes the syntax and purpose of commands such as CREATE DATABASE, CREATE TABLE, INSERT, SELECT, WHERE, ORDER BY, GROUP BY, and DROP TABLE, as well as functions like COUNT, MIN, MAX, and logical operators LIKE, BETWEEN, and NULL. The document also lists different data types and provides examples of queries using the various SQL statements and functions.
PL/SQL provides three collection types: associative arrays, nested tables, and variable-size arrays. Associative arrays use keys to access unbounded elements, nested tables are like one-dimensional arrays with an arbitrary number of elements, and variable-size arrays store a fixed number of elements in sequential order. Both associative arrays and nested tables can have object types as elements, but only nested tables can be stored in database columns.
Here, you can get the overview of PERL extraction language. PERL looks like a C-language. so you can learn quickly. at the end of slide you feel you will be familiar with PERL.
This document provides an overview of SQL (Structured Query Language) and examples of common SQL statements. SQL is a standard language for accessing and manipulating databases. It can be used to query databases, insert/update/delete records, and create/modify database structures. The document then demonstrates SQL statements for selecting, filtering, ordering, grouping, joining, and aggregating data. It also covers SQL functions, expressions, and wildcards that can be used in queries.
The Cape Cod house style originated in 17th century New England and was most popular in the 1930s. These 1-11⁄2 story homes were typically made of wood covered by clapboard or shingles, with a steep roof and central chimney connected to fireplaces in each room. Cape Cod homes were symmetrical and common in New England.
Farheen abdul hameed ip project (MY SQL);abdul talha
The document provides information on various SQL commands and functions for creating and managing databases and tables, inserting and retrieving data, and performing queries. It includes the syntax and purpose of commands such as CREATE DATABASE, CREATE TABLE, INSERT, SELECT, WHERE, ORDER BY, GROUP BY, and DROP TABLE, as well as functions like COUNT, MIN, MAX, and logical operators LIKE, BETWEEN, and NULL. The document also lists different data types and provides examples of queries using the various SQL statements and functions.
PL/SQL provides three collection types: associative arrays, nested tables, and variable-size arrays. Associative arrays use keys to access unbounded elements, nested tables are like one-dimensional arrays with an arbitrary number of elements, and variable-size arrays store a fixed number of elements in sequential order. Both associative arrays and nested tables can have object types as elements, but only nested tables can be stored in database columns.
Here, you can get the overview of PERL extraction language. PERL looks like a C-language. so you can learn quickly. at the end of slide you feel you will be familiar with PERL.
This document provides an overview of SQL (Structured Query Language) and examples of common SQL statements. SQL is a standard language for accessing and manipulating databases. It can be used to query databases, insert/update/delete records, and create/modify database structures. The document then demonstrates SQL statements for selecting, filtering, ordering, grouping, joining, and aggregating data. It also covers SQL functions, expressions, and wildcards that can be used in queries.
The Cape Cod house style originated in 17th century New England and was most popular in the 1930s. These 1-11⁄2 story homes were typically made of wood covered by clapboard or shingles, with a steep roof and central chimney connected to fireplaces in each room. Cape Cod homes were symmetrical and common in New England.
Phoenix Worldwide is a young and dynamic organization founded in the year 2015, by two professionals Rajesh Singh and Saurabh Ranjan, serving the industry for almost last two decades. We operate from Pune and Silvassa locations and offer comprehensive workforce solutions to the organizations, predominantly the start-ups and SMEs, individuals and academic institutions. Phoenix Worldwide is a strategic human capital consulting organization with a complete array of capabilities in HR outsourcing & Consulting, Executive Search, Survey & Assessment, HR Compliance & Audits, HR Automation, Organization Transformation, and Learning & Development. We aggressively partner to provide strategic support to serve your HR needs and meet the overall business objectives. We work closely with HR leaders and functional managers to ensure their strategies correlate with intended results.
Dokumen ini membahas model distribusi normal untuk variabel acak tidak seragam, baik diskrit maupun kontinu. Contoh limit theorem dan rumusan distribusi normal diskrit dipaparkan beserta contoh penerapannya untuk menentukan hasil permainan berdasarkan nilai acak yang mengikuti distribusi normal tertentu. Contoh perhitungan untuk menentukan hasil permainan R1 hingga R2 pun dijelaskan.
Παρουσίασή μου για τη βάση δεδομένων PostgreSQL και των δυνατοτήτων Data Replication που προσφέρει, στα πλαίσια του 6ου Συνεδρίου Κοινοτήτων Ανοιχτού Λογισμικού FOSSCOMM 2013 στις 21/4/2013 στο Χαροκόπειο Πανεπιστήμιο Αθηνών.
An investigation of how PostgreSQL and its latest capabilities (JSONB data type, GIN indices, Full Text Search) can be used to store, index and perform queries on structured Bibliographic Data such as MARC21/MARCXML, breaking the dependence on proprietary and arcane or obsolete software products.
Talk presented at FOSDEM 2016 in Brussels on 31/01/2016. This is a very practical & hands-on presentation with example code which is certainly not optimal ;)
Ace 10 high efficiency plumbing fixtures are flush with savingsTroy Aichele
This document discusses water conservation efforts at a 340-bed acute care facility in Olympia, WA. It details the replacement of 723 plumbing fixtures in 2009, including high-efficiency toilets, urinals, showerheads, and faucets. This led to a reduction in water consumption of over 3 million gallons compared to 2008 despite a 4.2% increase in patient census. Lessons learned from the project and its cost-effectiveness are also discussed.
Watersmart innovations 2010 cost of capacityTroy Aichele
The document compares the costs of various methods of increasing water and sewer capacity. It provides examples of costs to build new water wells, water treatment plants, sewer plants, and conservation methods. The cost per additional gallon of capacity varies widely between methods, from $7.80 per gallon for high efficiency shower heads to over $50 per gallon for pint urinals or desalination plants. Conservation methods generally have lower per-gallon costs than developing new infrastructure sources. Time frames to implement different options also range from months for conservation to over 5 years for large infrastructure projects.
Ace 10 conference green plumbersusa - 2 tips from each of the 5 core coursesTroy Aichele
This document summarizes the history and programs of Genesis Water Technologies from 2007 to 2012. It launched its website in January 2008 and held beta workshops that year. By the end of 2008, it had trained over 3,000 general practitioners through over 100 workshops in all 50 US states. The company expanded its training programs through online and "train the trainer" courses with a focus on water efficiency. It aimed to have its conservation programs adopted by 40,000 champions by 2012.
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλονJimmy Angelakos
Παρουσίασή μου για τη βάση δεδομένων PostgreSQL και τη χρήση της σε επιχειρησιακό περιβάλλον, στα πλαίσια της εκδήλωσης "Προηγμένες Εφαρμογές της βάσης δεδομένων PostgreSQL" στις 26/6/2013 στο Εθνικό Ίδρυμα Ερευνών.
1. The document discusses database design and SQL queries. It reviews relational algebra operators and provides SQL equivalents.
2. Examples are given to demonstrate conceptual evaluation of SQL queries by applying relational algebra operations. Nested queries, aggregate functions, and other SQL concepts are also covered.
3. The document concludes with examples of using aggregate operators like COUNT, SUM, AVG, MAX, and MIN in SQL queries.
This document provides an overview of SQL (Structured Query Language) including its history, data definition and manipulation capabilities. Key topics covered include SQL's data types, basic queries using SELECT, FROM and WHERE clauses, joins, aggregation, null values, triggers and indexes. The document also discusses SQL standards over time and commercial database implementations of SQL features.
This document discusses SQL commands for creating tables, adding data, and enforcing integrity constraints. It covers the core SQL commands: DDL for defining schema, DML for manipulating data, DCL for controlling access, DQL for querying data, and TCL for transactions. Specific topics summarized include data types, primary keys, foreign keys, indexes, views, stored procedures, functions and triggers. Integrity constraints like NOT NULL, UNIQUE, CHECK, DEFAULT are explained. The document also covers SQL queries with filtering, sorting, patterns and ranges. Authorization using GRANT and REVOKE commands is briefly covered.
This document provides information and resources for the Cassandra certification workshop, including:
- Details on the Administrator and Developer certifications and required resources
- A 6-step process for obtaining certification, including completing courses on the DataStax Academy platform and scheduling an exam
- Practice questions covering Cassandra query language (CQL) concepts tested in the certification exams
- A demonstration of the certification process
This document summarizes key points from a lecture on Relational Calculus:
- Relational Calculus is a formal, logical way to define queries by specifying the desired result rather than how to compute it. There are two flavors: Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC).
- TRC uses tuple variables and allows specifying queries like "Find all sailors with a rating above 7" as {S | S ∈ Sailors ∧ S.rating > 7}.
- Logical operators like ∧, ∨, ¬, ∀, ∃ allow combining atomic formulas to build more complex queries involving joins, projections, and other operations.
This document provides an overview of SQL and MySQL. It discusses topics such as creating and deleting databases and tables, importing data, using IDEs like Execute Query, configuring connections, performing queries with SELECT statements including filters, joins, and aggregates, updating and deleting data, indexing, and working with dates, strings, and numbers. Examples of SQL queries are provided throughout to demonstrate different SQL syntax and functions.
This document provides information about SQL and database management systems. It discusses:
- SQL is a standard language for querying, manipulating, and defining data in databases. It was developed by IBM in the 1970s.
- SQL can be used to perform functions like retrieving data from a database, inserting new records, updating existing records, and deleting records.
- The main components of SQL are DDL, DML, DCL, and DQL which allow creating, modifying and deleting database structures, manipulating data, controlling access to data, and querying data respectively.
- Common SQL statements are discussed including SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TABLE, and DROP TABLE. Data types and
SQL is a language for working with relational databases and querying the data within them. It began as SEQUEL in the 1970s and has since been standardized into different versions by ANSI and ISO. SQL allows users to define schemas, manipulate data, and write complex queries across multiple tables. The document provides an overview of SQL's core functionality, including data definition, manipulation, basic syntax, and examples of common queries.
The document summarizes key topics in database integrity and performance, including:
- Primary and foreign key constraints to prevent duplicate and dangling tuples
- Attribute and tuple constraints to enforce data integrity
- Views to provide virtual subsets and joins of database relations
- Indexes to enable fast search through tables
The document discusses these concepts over multiple pages and provides examples to illustrate primary keys, foreign keys, constraints, views and indexing. It concludes by offering feedback on students' report proposals, emphasizing depth over breadth and a focus on design over implementation.
Phoenix Worldwide is a young and dynamic organization founded in the year 2015, by two professionals Rajesh Singh and Saurabh Ranjan, serving the industry for almost last two decades. We operate from Pune and Silvassa locations and offer comprehensive workforce solutions to the organizations, predominantly the start-ups and SMEs, individuals and academic institutions. Phoenix Worldwide is a strategic human capital consulting organization with a complete array of capabilities in HR outsourcing & Consulting, Executive Search, Survey & Assessment, HR Compliance & Audits, HR Automation, Organization Transformation, and Learning & Development. We aggressively partner to provide strategic support to serve your HR needs and meet the overall business objectives. We work closely with HR leaders and functional managers to ensure their strategies correlate with intended results.
Dokumen ini membahas model distribusi normal untuk variabel acak tidak seragam, baik diskrit maupun kontinu. Contoh limit theorem dan rumusan distribusi normal diskrit dipaparkan beserta contoh penerapannya untuk menentukan hasil permainan berdasarkan nilai acak yang mengikuti distribusi normal tertentu. Contoh perhitungan untuk menentukan hasil permainan R1 hingga R2 pun dijelaskan.
Παρουσίασή μου για τη βάση δεδομένων PostgreSQL και των δυνατοτήτων Data Replication που προσφέρει, στα πλαίσια του 6ου Συνεδρίου Κοινοτήτων Ανοιχτού Λογισμικού FOSSCOMM 2013 στις 21/4/2013 στο Χαροκόπειο Πανεπιστήμιο Αθηνών.
An investigation of how PostgreSQL and its latest capabilities (JSONB data type, GIN indices, Full Text Search) can be used to store, index and perform queries on structured Bibliographic Data such as MARC21/MARCXML, breaking the dependence on proprietary and arcane or obsolete software products.
Talk presented at FOSDEM 2016 in Brussels on 31/01/2016. This is a very practical & hands-on presentation with example code which is certainly not optimal ;)
Ace 10 high efficiency plumbing fixtures are flush with savingsTroy Aichele
This document discusses water conservation efforts at a 340-bed acute care facility in Olympia, WA. It details the replacement of 723 plumbing fixtures in 2009, including high-efficiency toilets, urinals, showerheads, and faucets. This led to a reduction in water consumption of over 3 million gallons compared to 2008 despite a 4.2% increase in patient census. Lessons learned from the project and its cost-effectiveness are also discussed.
Watersmart innovations 2010 cost of capacityTroy Aichele
The document compares the costs of various methods of increasing water and sewer capacity. It provides examples of costs to build new water wells, water treatment plants, sewer plants, and conservation methods. The cost per additional gallon of capacity varies widely between methods, from $7.80 per gallon for high efficiency shower heads to over $50 per gallon for pint urinals or desalination plants. Conservation methods generally have lower per-gallon costs than developing new infrastructure sources. Time frames to implement different options also range from months for conservation to over 5 years for large infrastructure projects.
Ace 10 conference green plumbersusa - 2 tips from each of the 5 core coursesTroy Aichele
This document summarizes the history and programs of Genesis Water Technologies from 2007 to 2012. It launched its website in January 2008 and held beta workshops that year. By the end of 2008, it had trained over 3,000 general practitioners through over 100 workshops in all 50 US states. The company expanded its training programs through online and "train the trainer" courses with a focus on water efficiency. It aimed to have its conservation programs adopted by 40,000 champions by 2012.
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλονJimmy Angelakos
Παρουσίασή μου για τη βάση δεδομένων PostgreSQL και τη χρήση της σε επιχειρησιακό περιβάλλον, στα πλαίσια της εκδήλωσης "Προηγμένες Εφαρμογές της βάσης δεδομένων PostgreSQL" στις 26/6/2013 στο Εθνικό Ίδρυμα Ερευνών.
1. The document discusses database design and SQL queries. It reviews relational algebra operators and provides SQL equivalents.
2. Examples are given to demonstrate conceptual evaluation of SQL queries by applying relational algebra operations. Nested queries, aggregate functions, and other SQL concepts are also covered.
3. The document concludes with examples of using aggregate operators like COUNT, SUM, AVG, MAX, and MIN in SQL queries.
This document provides an overview of SQL (Structured Query Language) including its history, data definition and manipulation capabilities. Key topics covered include SQL's data types, basic queries using SELECT, FROM and WHERE clauses, joins, aggregation, null values, triggers and indexes. The document also discusses SQL standards over time and commercial database implementations of SQL features.
This document discusses SQL commands for creating tables, adding data, and enforcing integrity constraints. It covers the core SQL commands: DDL for defining schema, DML for manipulating data, DCL for controlling access, DQL for querying data, and TCL for transactions. Specific topics summarized include data types, primary keys, foreign keys, indexes, views, stored procedures, functions and triggers. Integrity constraints like NOT NULL, UNIQUE, CHECK, DEFAULT are explained. The document also covers SQL queries with filtering, sorting, patterns and ranges. Authorization using GRANT and REVOKE commands is briefly covered.
This document provides information and resources for the Cassandra certification workshop, including:
- Details on the Administrator and Developer certifications and required resources
- A 6-step process for obtaining certification, including completing courses on the DataStax Academy platform and scheduling an exam
- Practice questions covering Cassandra query language (CQL) concepts tested in the certification exams
- A demonstration of the certification process
This document summarizes key points from a lecture on Relational Calculus:
- Relational Calculus is a formal, logical way to define queries by specifying the desired result rather than how to compute it. There are two flavors: Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC).
- TRC uses tuple variables and allows specifying queries like "Find all sailors with a rating above 7" as {S | S ∈ Sailors ∧ S.rating > 7}.
- Logical operators like ∧, ∨, ¬, ∀, ∃ allow combining atomic formulas to build more complex queries involving joins, projections, and other operations.
This document provides an overview of SQL and MySQL. It discusses topics such as creating and deleting databases and tables, importing data, using IDEs like Execute Query, configuring connections, performing queries with SELECT statements including filters, joins, and aggregates, updating and deleting data, indexing, and working with dates, strings, and numbers. Examples of SQL queries are provided throughout to demonstrate different SQL syntax and functions.
This document provides information about SQL and database management systems. It discusses:
- SQL is a standard language for querying, manipulating, and defining data in databases. It was developed by IBM in the 1970s.
- SQL can be used to perform functions like retrieving data from a database, inserting new records, updating existing records, and deleting records.
- The main components of SQL are DDL, DML, DCL, and DQL which allow creating, modifying and deleting database structures, manipulating data, controlling access to data, and querying data respectively.
- Common SQL statements are discussed including SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE TABLE, and DROP TABLE. Data types and
SQL is a language for working with relational databases and querying the data within them. It began as SEQUEL in the 1970s and has since been standardized into different versions by ANSI and ISO. SQL allows users to define schemas, manipulate data, and write complex queries across multiple tables. The document provides an overview of SQL's core functionality, including data definition, manipulation, basic syntax, and examples of common queries.
The document summarizes key topics in database integrity and performance, including:
- Primary and foreign key constraints to prevent duplicate and dangling tuples
- Attribute and tuple constraints to enforce data integrity
- Views to provide virtual subsets and joins of database relations
- Indexes to enable fast search through tables
The document discusses these concepts over multiple pages and provides examples to illustrate primary keys, foreign keys, constraints, views and indexing. It concludes by offering feedback on students' report proposals, emphasizing depth over breadth and a focus on design over implementation.
Relational Calculus comes in two flavors: Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC). TRC uses tuple variables that range over tuples, like SQL. DRC uses variables that range over domain elements. Both are subsets of first-order logic. Relational Calculus expressions are queries that return tuples making a formula evaluate to true. The document discusses features of TRC like atomic formulas, free and bound variables, and how to write queries using selection, projection, joins and division. It also covers the expressive power of Relational Calculus and notes that queries written in it have the same capabilities as those written in Relational Algebra.
CS 542 Controlling Database Integrity and PerformanceJ Singh
This document summarizes a lecture on database integrity and performance. It discusses various techniques for ensuring database integrity, including primary key constraints to prevent duplicate tuples, foreign key constraints to prevent dangling references, and attribute constraints to prevent inconsistent attribute values. It also covers views, which allow querying virtual tables, and indexes to improve query performance by enabling faster searching. The document proposes discussing index structures and report topics at the next meeting.
The document provides an introduction to SQL and covers various SQL statements and operators including:
1. SQL statements like SELECT, INSERT, UPDATE, and DELETE are used to retrieve, modify and manipulate data in databases.
2. Operators like WHERE, BETWEEN, IN, LIKE and NULL are used to filter rows and compare values in conditions.
3. Functions and clauses such as SELECT, FROM, DISTINCT, GROUP BY, JOIN, ORDER BY, etc. are used to customize data retrieval and presentation.
This document provides an overview of Structured Query Language (SQL) including its core components: Data Definition Language (DDL) for defining database schemas, Data Manipulation Language (DML) for querying and modifying data, and Data Control Language (DCL) for managing permissions and transactions. It describes SQL statements for creating tables, defining constraints, and querying data using SELECT statements. Examples are provided to illustrate concepts like joins, aliases, and pattern matching. Data types, NULL handling, and nested queries are also summarized.
The document discusses Structured Query Language (SQL) and its basic statements. It covers:
- SQL is used to request and retrieve data from databases. The DBMS processes SQL queries and returns results.
- SQL statements are divided into DDL (data definition language) for managing schema, DML (data manipulation language) for data queries/modification, and DCL (data control language) for managing transactions and access control.
- The document provides examples of using SQL commands like CREATE TABLE, ALTER TABLE, DROP TABLE, INSERT, UPDATE, DELETE, SELECT and indexes. It also covers data types, constraints and operators used in SQL queries.
This document discusses how to create and manage database tables using SQL statements in Oracle. It covers topics such as naming rules for tables, the CREATE TABLE statement including specifying data types and constraints, accessing other users' tables, and making changes to existing tables using the ALTER TABLE statement. The goal is to teach how to categorize database objects, understand table structure, create tables with different constraints, and describe how schema objects work together.
The document discusses how to create and manage database tables. Key topics covered include using CREATE TABLE to define table structure, ALTER TABLE to modify tables, DROP TABLE to remove tables, and TRUNCATE TABLE to delete all rows. Datatypes, naming conventions, adding comments, and joining tables with subqueries are also summarized.
Lecture8-SQL-PartI-Jan30-2018 test Lecture8-SQL-PartI-Jan30-2018 testssuser9dddf7
This document summarizes a lecture on SQL (Structured Query Language). It introduces SQL's major aspects including data manipulation, definition, triggers, and more. It then covers basic SQL queries with SELECT, FROM, and WHERE clauses. Set operations like UNION and INTERSECT are discussed. Aggregate functions like COUNT, SUM, and GROUP BY are explained. The lecture concludes with ORDER BY to sort query results.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Azure Interview Questions and Answers PDF By ScholarHat
asal12 sqliii
1. SQL: The Query
Language
Part 3
CS186, Fall 2005
R &G - Chapters 5-6
It is not every question
that deserves an answer.
Publius Syrus. 42 B. C.
2. Null Values
• Field values in a tuple are sometimes unknown (e.g.,
a rating has not been assigned) or inapplicable (e.g.,
no spouse’s name).
– SQL provides a special value null for such situations.
• The presence of null complicates many issues. E.g.:
– Special operators needed to check if value is/is not null.
– Is rating>8 true or false when rating is equal to null? What
about AND, OR and NOT connectives?
– We need a 3-valued logic (true, false and unknown).
– Meaning of constructs must be defined carefully. (e.g.,
WHERE clause eliminates rows that don’t evaluate to true.)
– New operators (in particular, outer joins) possible/needed.
3. Joins
SELECT (column_list)
FROM table_name
[INNER | {LEFT |RIGHT | FULL } OUTER] JOIN table_name
ON qualification_list
WHERE …
Explicit join semantics needed unless it is an INNER
join
(INNER is default)
4. Inner Join
Only the rows that match the search conditions are
returned.
SELECT s.sid, s.name, r.bid
FROM Sailors s INNER JOIN Reserves r
ON s.sid = r.sid
Returns only those sailors who have reserved boats
SQL-92 also allows:
SELECT s.sid, s.name, r.bid
FROM Sailors s NATURAL JOIN Reserves r
“NATURAL” means equi-join for each pair of
attributes with the same name
5. SELECT s.sid, s.name, r.bid
FROM Sailors s INNER JOIN Reserves r
ON s.sid = r.sid
sid
22
31
95
sname rating age
Dustin
7
45.0
Lubber 8
55.5
Bob
3
63.5
sid bid
day
22 101 10/10/96
95 103 11/12/96
s.sid s.name r.bid
22 Dustin
101
95 Bob
103
6. Left Outer Join
Left Outer Join returns all matched rows, plus
all unmatched rows from the table on the left
of the join clause
(use nulls in fields of non-matching tuples)
SELECT s.sid, s.name, r.bid
FROM Sailors s LEFT OUTER JOIN Reserves r
ON s.sid = r.sid
Returns all sailors & information on whether
they have reserved boats
7. SELECT s.sid, s.name, r.bid
FROM Sailors s LEFT OUTER JOIN Reserves r
ON s.sid = r.sid
sid
22
31
95
sname rating age
Dustin
7
45.0
Lubber 8
55.5
Bob
3
63.5
s.sid
22
95
31
sid bid
day
22 101 10/10/96
95 103 11/12/96
s.name r.bid
Dustin
101
Bob
103
Lubber
8. Right Outer Join
Right Outer Join returns all matched rows, plus
all unmatched rows from the table on the
right of the join clause
SELECT r.sid, b.bid, b.name
FROM Reserves r RIGHT OUTER JOIN Boats b
ON r.bid = b.bid
Returns all boats & information on which ones
are reserved.
9. SELECT r.sid, b.bid, b.name
FROM Reserves r RIGHT OUTER JOIN Boats b
ON r.bid = b.bid
sid bid
day
22 101 10/10/96
95 103 11/12/96
r.sid
bid
101
102
103
104
b.bid
22
95
101
102
103
104
bname
Interlake
Interlake
Clipper
Marine
b.name
Interlake
Interlake
Clipper
Marine
color
blue
red
green
red
10. Full Outer Join
Full Outer Join returns all (matched or
unmatched) rows from the tables on both
sides of the join clause
SELECT r.sid, b.bid, b.name
FROM Reserves r FULL OUTER JOIN Boats b
ON r.bid = b.bid
Returns all boats & all information on
reservations
11. SELECT r.sid, b.bid, b.name
FROM Reserves r FULL OUTER JOIN Boats b
ON r.bid = b.bid
sid bid
22
95
day
101 10/10/96
103 11/12/96
r.sid
b.bid
22
95
bid
101
102
103
104
101
102
103
104
bname
Interlake
Interlake
Clipper
Marine
b.name
Interlake
Interlake
Clipper
Marine
color
blue
red
green
red
Note: in this case it is the same as the ROJ because
bid is a foreign key in reserves, so all reservations must
have a corresponding tuple in boats.
12. Conceptual SQL Evaluation
SELECT
[DISTINCT] target-list
FROM
relation-list
WHERE
qualification
GROUP BY grouping-list
HAVING
group-qualification
Project away columns
(just keep those used in
SELECT, GBY, HAVING)
SELECT
[DISTINCT]
Eliminate
duplicates
Apply selections
(eliminate rows)
WHERE
HAVING
Eliminate
groups
Relation
cross-product
FROM
GROUP BY
Form groups
& aggregate
13. Sorting the Results of a Query
• ORDER BY column [ ASC | DESC] [, ...]
SELECT S.rating, S.sname, S.age
FROM Sailors S, Boats B, Reserves R
WHERE S.sid=R.sid
AND R.bid=B.bid AND B.color=‘red’
ORDER BY S.rating, S.sname;
• Can order by any column in SELECT list,
including expressions or aggs:
SELECT S.sid, COUNT (*) AS redrescnt
FROM Sailors S, Boats B, Reserves R
WHERE S.sid=R.sid
AND R.bid=B.bid AND B.color=‘red’
GROUP BY S.sid
ORDER BY redrescnt DESC;
14. Views: Defining External DB
Schemas
CREATE VIEW view_name
AS select_statement
Makes development simpler
Often used for security
Not instantiated - makes updates tricky
CREATE VIEW Reds
AS SELECT B.bid, COUNT (*) AS scount
FROM Boats B, Reserves R
WHERE R.bid=B.bid AND B.color=‘red’
GROUP BY B.bid
15. Views Instead of Relations in
Queries
CREATE VIEW Reds
AS SELECT B.bid, COUNT (*) AS scount
FROM Boats B, Reserves R
WHERE R.bid=B.bid AND B.color=‘red’
GROUP BY B.bid
b.bid
scount
102
1
Reds
SELECT bname, scount
FROM Reds R, Boats B
WHERE R.bid=B.bid
AND scount < 10
16. Discretionary Access Control
GRANT privileges ON object TO users
[WITH GRANT OPTION]
• Object can be a Table or a View
• Privileges can be:
• Select
• Insert
• Delete
• References (cols) – allow to create a
foreign key that references the specified
column(s)
• All
• Can later be REVOKEd
• Users can be single users or groups
17. Two more important topics
• Constraints
• SQL embedded in other languages
18. Integrity Constraints (Review)
• An IC describes conditions that every legal
instance of a relation must satisfy.
– Inserts/deletes/updates that violate IC’s are disallowed.
– Can be used to ensure application semantics (e.g., sid is
a key), or prevent inconsistencies (e.g., sname has to be
a string, age must be < 200)
• Types of IC’s : Domain constraints, primary key
constraints, foreign key constraints, general
constraints.
– Domain constraints: Field values must be of right type.
Always enforced.
– Primary key and foreign key constraints: you know them.
19. General
Constraints
•
•
•
•
CREATE TABLE Sailors
( sid INTEGER,
sname CHAR(10),
rating INTEGER,
age REAL,
Useful when
PRIMARY KEY (sid),
more general ICs
CHECK ( rating >= 1
than keys are
AND rating <=
involved.
CREATE TABLE Reserves
Can use queries
( sname CHAR(10),
to express
bid INTEGER,
constraint.
day DATE,
Checked on
PRIMARY KEY (bid,day),
insert or update.
CONSTRAINT noInterlakeRes
Constraints can
CHECK (`Interlake’ <>
be named.
( SELECT B.bname
FROM Boats B
WHERE B.bid=bid)))
10 ))
20. Constraints Over Multiple Relations
•
•
•
•
•
•
CREATE TABLE Sailors
( sid INTEGER,
Number of boats
sname CHAR(10),
plus number of
rating INTEGER,
Awkward and
sailors is < 100
wrong!
age REAL,
Only checks
PRIMARY KEY (sid),
sailors!
Only required to CHECK
hold if the
( (SELECT COUNT (S.sid) FROM Sailors S)
associated table is
+ (SELECT COUNT (B.bid) FROM
non-empty.
ASSERTION is the
right solution; not
associated with
either table.
Unfortunately, not
supported in many
DBMS.
Triggers are
Boats B) < 100 )
CREATE ASSERTION smallClub
CHECK
( (SELECT COUNT (S.sid) FROM Sailors
+ (SELECT COUNT (B.bid)
FROM Boats B) < 100 )
S)
21. Writing Applications with SQL
• SQL is not a general purpose programming
language.
+ Tailored for data retrieval and manipulation
+ Relatively easy to optimize and parallelize
- Can’t write entire apps in SQL alone
Options:
Make the query language “Turing complete”
Avoids the “impedance mismatch”
but, loses advantages of relational language simplicity
Allow SQL to be embedded in regular programming
languages.
Q: What needs to be solved to make the latter
approach work?
22. Embedded SQL
•
DBMS vendors usually provide “host language bindings”
•
General pattern
•
•
–
–
–
–
E.g. for C or COBOL
Allow SQL statements to be called from within a program
Typically you preprocess your programs
Preprocessor generates calls to a proprietary DB connectivity
library
– One call to connect to the right database (login, etc.)
– SQL statements can refer to host variables from the
language
Typically vendor-specific
– We won’t look at any in detail, we’ll look at standard stuff
Problem
– SQL relations are (multi-)sets, no a priori bound on the
number of records. No such data structure in C.
– SQL supports a mechanism called a cursor to handle this.
23. Just to give you a flavor
EXEC SQL SELECT S.sname, S.age
INTO :c_sname,:c_age
FROM Sailors S
WHERE S.sid = :c_sid
24. Cursors
•
•
•
•
•
Can declare a cursor on a relation or query
Can open a cursor
Can repeatedly fetch a tuple (moving the cursor)
Special return value when all tuples have been retrieved.
ORDER BY allows control over the order in which tuples are
returned.
• Fields in ORDER BY clause must also appear in SELECT clause.
•
•
Can also modify/delete tuple pointed to by a cursor
– A “non-relational” way to get a handle to a particular tuple
There’s an Embedded SQL syntax for cursors
– DECLARE <cursorname> CURSOR FOR <select stmt>
– FETCH FROM <cursorname> INTO <variable names>
– But we’ll use JDBC instead
25. Database APIs: Alternative to
embedding
• Rather than modify compiler, add a library
with database calls (API)
– special procedures/objects
– passes SQL strings from language, presents
result sets in a language-friendly way
– ODBC a C/C++ standard started on Windows
– JDBC a Java equivalent
– Most scripting languages have similar things
• E.g. For Perl there is DBI, “oraPerl”, other packages
• Mostly DBMS-neutral
– at least try to hide distinctions across different
DBMSs
26. Architecture
Application
ODBC driver
Data Source
• A lookup service maps “data source names” (“DSNs”) to drivers
– Typically handled by OS
•
•
•
•
Based on the DSN used, a “driver” is linked into the app at runtime
The driver traps calls, translates them into DBMS-specific code
Database can be across a network
ODBC is standard, so the same program can be used (in principle) to
access multiple database systems
• Data source may not even be an SQL database!
27. ODBC/JDBC
• Various vendors provide drivers
– MS bundles a bunch into Windows
– Vendors like DataDirect and OpenLink sell drivers for
multiple OSes
• Drivers for various data sources
– Relational DBMSs (Oracle, DB2, SQL Server, Informix, etc.)
– “Desktop” DBMSs (Access, Dbase, Paradox, FoxPro, etc.)
– Spreadsheets (MS Excel, Lotus 1-2-3, etc.)
– Delimited text files (.CSV, .TXT, etc.)
• You can use JDBC/ODBC client s over many data
sources
– E.g. MS Query comes with many versions of MS Office
(msqry32.exe)
• Can write your own Java or C++ programs against
xDBC
28. JDBC
• Part of Java, very easy to use
• Java comes with a JDBC-to-ODBC bridge
– So JDBC code can talk to any ODBC data source
– E.g. look in your Windows Control Panel for
JDBC/ODBC drivers!
• JDBC tutorial online
– http://developer.java.sun.com/developer/Books/JDBC
Tutorial/
29. JDBC Basics: Connections
• A Connection is an object representing a login to a
database
// GET CONNECTION
Connection con;
try {
con = DriverManager.getConnection(
"jdbc:odbc:sailorsDB",
userName,password);
} catch(Exception e){ System.out.println(e);
• Eventually you close the connection
// CLOSE CONNECTION
try { con.close(); }
catch (Exception e) { System.out.println(e); }
}
30. JDBC Basics: Statements
• You need a Statement object for each SQL
statement
// CREATE STATEMENT
Statement stmt;
try {
stmt = con.createStatement();
} catch (Exception e){
System.out.println(e);
}
Soon we’ll say stmt.executeQuery(“select …”);
31. CreateStatement cursor behavior
•
•
•
•
Two optional args to createStatement:
– createStatement(ResultSet.<TYPE>,
ResultSet.<CONCUR>)
– Corresponds to SQL cursor features
<TYPE> is one of
– TYPE_FORWARD_ONLY: can’t move cursor backward
– TYPE_SCROLL_INSENSITIVE: can move backward, but doesn’t
show results of any updates
– TYPE_SCROLL_SENSITIVE: can move backward, will show
updates made while result set is open
<CONCUR> is one of
– CONCUR_READ_ONLY: this statement doesn’t allow updates
– CONCUR_UPDATABLE: this statement allows updates
Defaults:
– TYPE_FORWARD_ONLY and CONCUR_READ_ONLY
32. JDBC Basics: ResultSet
•
•
A ResultSet object serves as a cursor for the statement’s
results (stmt.executeQuery() )
// EXECUTE QUERY
ResultSet results;
try {
results = stmt.executeQuery(
"select * from Sailors")
} catch (Exception e){
System.out.println(e); }
Obvious handy methods:
– results.next() advances cursor to next tuple
• Returns “false” when the cursor slides off the table (beginning or end)
– “scrollable” cursors:
• results.previous(), results.relative(int), results.absolute(int),
results.first(), results.last(), results.beforeFirst(), results.afterLast()
33. ResultSet Metadata
•
Can find out stuff about the ResultSet schema via
ResultSetMetaData
ResultSetMetaData rsmd = results.getMetaData();
int numCols = rsmd.getColumnCount();
int i, rowcount = 0;
•
// get column header info
for (i=1; i <= numCols; i++){
if (i > 1) buf.append(",");
buf.append(rsmd.getColumnLabel(i));
}
buf.append("n");
Other ResultSetMetaData methods:
– getColumnType(i), isNullable(i), etc.
34. Getting Values in Current of Cursor
• getString
// break it off at 100 rows max
while (results.next() && rowcount < 100){
// Loop through each column, getting the
// column data and displaying
for (i=1; i <= numCols; i++) {
if (i > 1) buf.append(",");
buf.append(results.getString(i));
}
buf.append("n");
rowcount++;
•
}
Similarly, getFloat, getInt, etc.
35. Updating Current of Cursor
• Update fields in current of cursor:
result.next();
result.updateInt("Rating", 10);
• Also updateString, updateFloat, etc.
• Or can always submit a full SQL UPDATE
statement
– Via executeQuery()
• The original statement must have been
CONCUR_UPDATABLE in either case!
36. Cleaning up Neatly
try {
// CLOSE RESULT SET
results.close();
// CLOSE STATEMENT
stmt.close();
// CLOSE CONNECTION
con.close();
} catch (Exception e) {
System.out.println(e);
}
37. Putting it Together (w/o try/catch)
Connection con =
DriverManager.getConnection("jdbc:odbc:weblog",userN
ame,password);
Statement stmt = con.createStatement();
ResultSet results =
stmt.executeQuery("select * from Sailors")
ResultSetMetaData rsmd = results.getMetaData();
int numCols = rsmd.getColumnCount(), i;
StringBuffer buf = new StringBuffer();
while (results.next() && rowcount < 100){
for (i=1; i <= numCols; i++) {
if (i > 1) buf.append(",");
buf.append(results.getString(i));
}
buf.append("n");
}
results.close(); stmt.close(); con.close();
38. Similar deal for web scripting languages
• Common scenario today is to have a web
client
– A web form issues a query to the DB
– Results formatted as HTML
• Many web scripting languages used
– jsp, asp, PHP, etc.
– most of these are similar, look a lot like JDBC with
HTML mixed in
40. API Summary
APIs are needed to interface DBMSs to
programming languages
• Embedded SQL uses “native drivers” and is
usually faster but less standard
• ODBC (used to be Microsoft-specific) for C/C++
• JDBC the standard for Java
• Scripting languages (PHP, Perl, JSP) are
becoming the preferred technique for web-based
Editor's Notes
The slides for this text are organized into several modules. Each lecture contains about enough material for a 1.25 hour class period. (The time estimate is very approximate--it will vary with the instructor, and lectures also differ in length; so use this as a rough guideline.) This covers Lectures 3 and 4 (of 6) in Module (3).
Module (1): Introduction (DBMS, Relational Model)
Module (2): Storage and File Organizations (Disks, Buffering, Indexes)
Module (3): Database Concepts (Relational Queries, DDL/ICs, Views and Security)
Module (4): Relational Implementation (Query Evaluation, Optimization)
Module (5): Database Design (ER Model, Normalization, Physical Design, Tuning)
Module (6): Transaction Processing (Concurrency Control, Recovery)
Module (7): Advanced Topics