The document discusses views in SQL. It defines views as logical tables that represent data from one or more underlying tables. Views can be queried, updated, and deleted from like tables but do not occupy storage space. The document describes simple views based on a single table and complex views involving joins across multiple tables. It provides examples of creating, modifying, dropping, and querying views. The document also discusses indexes in SQL, describing them as pointers that speed up data retrieval. It covers B-tree and bitmap indexes and provides examples of creating indexes on tables.
This document provides an introduction to SQL (Structured Query Language) for manipulating and working with data. It covers SQL fundamentals including defining a database using DDL, working with views, writing queries, and establishing referential integrity. It also discusses SQL data types, database definition, creating tables and views, and key SQL statements for data manipulation including SELECT, INSERT, UPDATE, and DELETE. Examples are provided for creating tables and views, inserting, updating, and deleting data, and writing queries using functions, operators, sorting, grouping, and filtering.
SQLFire is a scalable SQL database that provides an alternative to NoSQL databases by using SQL instead. It features hash partitioning, entity groups to colocate related data, and data aware stored procedures that can run queries in parallel across partitions. SQLFire uses a tunable consistency model and supports distributed transactions without global locks. Data is stored primarily in memory but can optionally be persisted to disk in parallel for high throughput writes without seeks. Benchmark results showed SQLFire can scale linearly from 2 to 10 servers and 200 to 1200 clients.
This document provides an overview of SQL data definition and manipulation commands including INSERT, UPDATE, DELETE, SELECT and the CASE expression. It describes how to add, modify and remove rows from tables. It also covers selecting columns, arithmetic expressions, column aliases, concatenation, literals, DISTINCT, and conditional logic using the CASE expression. Care is advised when using DELETE and UPDATE to avoid removing unintended data.
The document discusses various SQL concepts including creating and dropping databases and tables, data types, SQL statements for inserting, updating and deleting records, joining tables, and aggregation functions. It provides syntax and examples for commands like CREATE DATABASE, CREATE TABLE, INSERT, UPDATE, DELETE, SELECT, WHERE, GROUP BY, UNION and functions like COUNT, SUM, AVG, MAX, MIN. The document is meant as a guide for students to learn fundamental SQL concepts through explanations, syntax and hands-on activities like creating a table.
1) SQL is a language used to manage data in relational database management systems. It allows users to define, manipulate, and control access to data.
2) SQL statements like SELECT, INSERT, UPDATE, DELETE allow users to retrieve, add, modify and remove data from database tables.
3) SQL also includes statements for defining the structure of a database through data definition language commands like CREATE DATABASE, CREATE TABLE.
This document provides an overview of SQL programming including:
- A brief history of SQL and how it has evolved over time.
- Key SQL fundamentals like database structures, tables, relationships, and normalization.
- How to define and modify database structures using commands like CREATE, ALTER, DROP.
- How to manipulate data using INSERT, UPDATE, DELETE, and transactions.
- How to retrieve data using SELECT statements, joins, and other techniques.
- How to aggregate data using functions like SUM, AVG, MAX, MIN, and COUNT.
- Additional topics covered include subqueries, views, and resources for further learning.
This document discusses the data definition language (DDL) statements in SQLite that define and modify database schemas. It covers the CREATE, ALTER TABLE, and DROP statements. CREATE is used to make tables, indexes, views and triggers. ALTER TABLE renames tables and adds columns. DROP removes tables, indexes, views and triggers. Examples demonstrate creating a simple table, renaming it, and adding a column using these statements.
The document discusses how to create and modify Oracle tables using SQL. It describes how to use the CREATE TABLE statement to define a table's structure, columns, constraints, and storage parameters. It also explains how to view table metadata using data dictionary views, add comments to tables and columns, and alter existing tables by adding or modifying columns while following certain restrictions.
This document provides an overview of SQL (Structured Query Language) and its main components. It discusses SQL query types like SELECT, INSERT, UPDATE, and DELETE statements. It also covers SQL joins, aliases, clauses, functions, conditions, tables and views. Finally, it provides examples and practice exercises for the SELECT and INSERT statements.
This document describes various database objects like sequences, indexes, and synonyms. It explains that sequences are used to automatically generate primary keys and improve efficiency. Indexes speed up queries by indexing columns frequently used in WHERE clauses. Synonyms provide alternative names for objects to simplify access. The document provides examples of creating, modifying, viewing, and dropping these database objects using SQL statements.
Modern SQL in Open Source and Commercial DatabasesMarkus Winand
SQL has gone out of fashion lately—partly due to the NoSQL movement, but mostly because SQL is often still used like 20 years ago. As a matter of fact, the SQL standard continued to evolve during the past decades resulting in the current release of 2016. In this session, we will go through the most important additions since the widely known SQL-92. We will cover common table expressions and window functions in detail and have a very short look at the temporal features of SQL:2011 and row pattern matching from SQL:2016.
Links:
http://modern-sql.com/
http://winand.at/
http://sql-performance-explained.com/
This document provides an overview of database concepts including creating, altering, and dropping databases and tables. It discusses data definition language (DDL) commands like CREATE, ALTER, DROP as well as data manipulation language (DML) commands like INSERT, SELECT, UPDATE, DELETE. It also covers database constraints, joins, functions for aggregation, strings, numbers, dates and more. The document is an introduction to core SQL concepts for a course on data management and database design.
This document provides an overview of SQL (Structured Query Language) in 3 sentences or less:
SQL is a standard language for storing, manipulating and retrieving data in relational database systems. The document outlines various SQL commands, clauses, and functions for working with data types, tables, queries, procedures, indexes and more. Examples are provided to illustrate how to use SQL statements to define schemas, insert, update, select and manipulate data in relational database tables.
SQL is a language used to store, manipulate, and retrieve data in relational database management systems. The core SQL commands are CREATE, SELECT, INSERT, UPDATE, and DELETE. CREATE is used to create new tables and objects. SELECT retrieves data from tables. INSERT adds new rows of data. UPDATE modifies existing data. DELETE removes rows of data. SQL allows users and applications to access data, define data structures, and manage data.
Designing and Creating Views, Inline Functions, and SynonymsTayba Farooqui
Views allow users to query data from multiple tables while hiding complexity. Views are defined with a SELECT statement and do not store data. Inline functions can be used like parameterized views by accepting parameters. Synonyms provide an abstraction layer and can be used to reference objects in other databases or schemas.
The document discusses SQL database commands including DDL commands like CREATE, ALTER, DROP and TRUNCATE used to build and modify database structures. It describes using CREATE TABLE to generate tables with data types like VARCHAR2, CHAR, NUMBER, DATE and LOB types. ALTER TABLE adds, deletes or modifies columns and constraints. DROP TABLE deletes tables. DML commands like INSERT INTO, UPDATE and DELETE are used to add, modify and remove data from tables.
The document discusses various schema object management techniques in Oracle including:
1) Adding, modifying, and dropping columns using the ALTER TABLE statement.
2) Adding constraints such as primary keys, foreign keys, and indexes.
3) Creating function-based indexes and dropping indexes.
4) Using Flashback operations to restore tables.
5) Creating and querying external tables stored in operating system files.
The document discusses controlling user access in a database. It covers creating users and roles, granting and revoking privileges, and managing object and system privileges. The DBA can create users and roles, and grant privileges to access objects and the database. Users can be granted specific privileges on tables, views, and other objects. Privileges can later be revoked from users as needed.
Standard SQL features where PostgreSQL beats its competitorsMarkus Winand
The SQL standard has more than 4300 pages and hundreds of optional features. The number of features offered by different products varies vastly. PostgreSQL implements a relativley large number of them.
In this session I present some standard SQL features that work in PostgreSQL, but not in other popular open-source databases. But when it comes to standard conformance, PostgreSQL doesn’t even need to fear the comparison to its commercial competitors: PostgreSQL also supports a few useful standard SQL features that don’t work in any of the three most popular commercial SQL databases.
The document discusses various SQL concepts like views, triggers, functions, indexes, joins, and stored procedures. Views are virtual tables created by joining real tables, and can be updated, modified or dropped. Triggers automatically run code when data is inserted, updated or deleted from a table. Functions allow reusable code and improve clarity. Indexes allow faster data retrieval. Joins combine data from different tables. Stored procedures preserve data integrity.
SQL is a relational database language used to define, manipulate, and control access to data in a relational database. SQL statements are used to perform tasks like data retrieval, insertion, deletion, updating and table/database management. The basic structure of an SQL query involves selecting data from one or more tables to display or use. SQL supports features like constraints, indexes, views, triggers that enforce data integrity and security.
Adbms 21 sql 99 schema definition constraints and queriesVaibhav Khanna
In SQL2, can use the CREATE TABLE command for specifying the primary key attributes, secondary keys, and referential integrity constraints (foreign keys).
Key attributes can be specified via the PRIMARY KEY and UNIQUE phrases
The document discusses how to use Oracle's Data Definition Language (DDL) to define database objects like tables, views, indexes, and sequences. It provides the syntax for creating these objects using commands like CREATE, ALTER, and DROP. Examples are given for creating a table with various constraints, altering a table, creating views with subqueries, and using sequences to generate primary keys. The key DDL commands, data types, naming conventions, constraints, and how to populate and modify tables are summarized.
This document discusses various data definition language (DDL) statements in SQL. It describes DDL statements to create, modify, and delete database objects like schemas, tables, views, and indexes. Specifically, it covers the CREATE, ALTER, and DROP statements for schemas, tables, views, indexes, and constraints. Examples are provided for each statement type.
SQL is a standard language used to manage data in relational database management systems. It can be used to create and modify database objects like tables and stored procedures, query and manipulate data, and set permissions. Common SQL statements include SELECT to query data, INSERT and UPDATE to modify data, CREATE and ALTER to define database structure, and DELETE to remove data. Transactions are managed using commands like COMMIT, ROLLBACK, and SAVEPOINT. Security is enforced using GRANT and REVOKE commands to manage user permissions on database objects.
The document describes various data definition language (DDL) and data manipulation language (DML) commands in MySQL. Some key commands include using CREATE to add new databases, tables, indexes, and constraints. ALTER is used to modify existing database objects. DROP removes databases, tables, columns or indexes. DML commands like SELECT are used to query data, WHERE filters rows, JOIN combines tables, and INSERT, UPDATE, DELETE modify data. COUNT, SUM, DISTINCT and other functions can be used to aggregate or transform result sets.
SQL is a language for communicating with a database management system (DBMS) to carry out tasks like querying data, inserting/updating/deleting rows, and managing database objects. It includes data definition language (DDL) for creating and modifying database objects and data manipulation language (DML) for querying and modifying data. A SQL database contains tables which have a schema defining columns and their data types, and may have constraints. Queries in SQL use SELECT statements to retrieve data that matches conditions specified in the WHERE clause by comparing column values and expressions.
The document discusses the relational model of databases. It defines key concepts like relations, tuples, attributes, domains, and keys. It provides an example database schema for an auction application with relations for owners, items, bids, and buyers. It explains that a relation is a set of tuples with a common schema where each tuple maps attribute names to values from predefined domains. It also defines the different types of keys like superkeys and primary keys.
The document discusses how to create and modify Oracle tables using SQL. It describes how to use the CREATE TABLE statement to define a table's structure, columns, constraints, and storage parameters. It also explains how to view table metadata using data dictionary views, add comments to tables and columns, and alter existing tables by adding or modifying columns while following certain restrictions.
This document provides an overview of SQL (Structured Query Language) and its main components. It discusses SQL query types like SELECT, INSERT, UPDATE, and DELETE statements. It also covers SQL joins, aliases, clauses, functions, conditions, tables and views. Finally, it provides examples and practice exercises for the SELECT and INSERT statements.
This document describes various database objects like sequences, indexes, and synonyms. It explains that sequences are used to automatically generate primary keys and improve efficiency. Indexes speed up queries by indexing columns frequently used in WHERE clauses. Synonyms provide alternative names for objects to simplify access. The document provides examples of creating, modifying, viewing, and dropping these database objects using SQL statements.
Modern SQL in Open Source and Commercial DatabasesMarkus Winand
SQL has gone out of fashion lately—partly due to the NoSQL movement, but mostly because SQL is often still used like 20 years ago. As a matter of fact, the SQL standard continued to evolve during the past decades resulting in the current release of 2016. In this session, we will go through the most important additions since the widely known SQL-92. We will cover common table expressions and window functions in detail and have a very short look at the temporal features of SQL:2011 and row pattern matching from SQL:2016.
Links:
http://modern-sql.com/
http://winand.at/
http://sql-performance-explained.com/
This document provides an overview of database concepts including creating, altering, and dropping databases and tables. It discusses data definition language (DDL) commands like CREATE, ALTER, DROP as well as data manipulation language (DML) commands like INSERT, SELECT, UPDATE, DELETE. It also covers database constraints, joins, functions for aggregation, strings, numbers, dates and more. The document is an introduction to core SQL concepts for a course on data management and database design.
This document provides an overview of SQL (Structured Query Language) in 3 sentences or less:
SQL is a standard language for storing, manipulating and retrieving data in relational database systems. The document outlines various SQL commands, clauses, and functions for working with data types, tables, queries, procedures, indexes and more. Examples are provided to illustrate how to use SQL statements to define schemas, insert, update, select and manipulate data in relational database tables.
SQL is a language used to store, manipulate, and retrieve data in relational database management systems. The core SQL commands are CREATE, SELECT, INSERT, UPDATE, and DELETE. CREATE is used to create new tables and objects. SELECT retrieves data from tables. INSERT adds new rows of data. UPDATE modifies existing data. DELETE removes rows of data. SQL allows users and applications to access data, define data structures, and manage data.
Designing and Creating Views, Inline Functions, and SynonymsTayba Farooqui
Views allow users to query data from multiple tables while hiding complexity. Views are defined with a SELECT statement and do not store data. Inline functions can be used like parameterized views by accepting parameters. Synonyms provide an abstraction layer and can be used to reference objects in other databases or schemas.
The document discusses SQL database commands including DDL commands like CREATE, ALTER, DROP and TRUNCATE used to build and modify database structures. It describes using CREATE TABLE to generate tables with data types like VARCHAR2, CHAR, NUMBER, DATE and LOB types. ALTER TABLE adds, deletes or modifies columns and constraints. DROP TABLE deletes tables. DML commands like INSERT INTO, UPDATE and DELETE are used to add, modify and remove data from tables.
The document discusses various schema object management techniques in Oracle including:
1) Adding, modifying, and dropping columns using the ALTER TABLE statement.
2) Adding constraints such as primary keys, foreign keys, and indexes.
3) Creating function-based indexes and dropping indexes.
4) Using Flashback operations to restore tables.
5) Creating and querying external tables stored in operating system files.
The document discusses controlling user access in a database. It covers creating users and roles, granting and revoking privileges, and managing object and system privileges. The DBA can create users and roles, and grant privileges to access objects and the database. Users can be granted specific privileges on tables, views, and other objects. Privileges can later be revoked from users as needed.
Standard SQL features where PostgreSQL beats its competitorsMarkus Winand
The SQL standard has more than 4300 pages and hundreds of optional features. The number of features offered by different products varies vastly. PostgreSQL implements a relativley large number of them.
In this session I present some standard SQL features that work in PostgreSQL, but not in other popular open-source databases. But when it comes to standard conformance, PostgreSQL doesn’t even need to fear the comparison to its commercial competitors: PostgreSQL also supports a few useful standard SQL features that don’t work in any of the three most popular commercial SQL databases.
The document discusses various SQL concepts like views, triggers, functions, indexes, joins, and stored procedures. Views are virtual tables created by joining real tables, and can be updated, modified or dropped. Triggers automatically run code when data is inserted, updated or deleted from a table. Functions allow reusable code and improve clarity. Indexes allow faster data retrieval. Joins combine data from different tables. Stored procedures preserve data integrity.
SQL is a relational database language used to define, manipulate, and control access to data in a relational database. SQL statements are used to perform tasks like data retrieval, insertion, deletion, updating and table/database management. The basic structure of an SQL query involves selecting data from one or more tables to display or use. SQL supports features like constraints, indexes, views, triggers that enforce data integrity and security.
Adbms 21 sql 99 schema definition constraints and queriesVaibhav Khanna
In SQL2, can use the CREATE TABLE command for specifying the primary key attributes, secondary keys, and referential integrity constraints (foreign keys).
Key attributes can be specified via the PRIMARY KEY and UNIQUE phrases
The document discusses how to use Oracle's Data Definition Language (DDL) to define database objects like tables, views, indexes, and sequences. It provides the syntax for creating these objects using commands like CREATE, ALTER, and DROP. Examples are given for creating a table with various constraints, altering a table, creating views with subqueries, and using sequences to generate primary keys. The key DDL commands, data types, naming conventions, constraints, and how to populate and modify tables are summarized.
This document discusses various data definition language (DDL) statements in SQL. It describes DDL statements to create, modify, and delete database objects like schemas, tables, views, and indexes. Specifically, it covers the CREATE, ALTER, and DROP statements for schemas, tables, views, indexes, and constraints. Examples are provided for each statement type.
SQL is a standard language used to manage data in relational database management systems. It can be used to create and modify database objects like tables and stored procedures, query and manipulate data, and set permissions. Common SQL statements include SELECT to query data, INSERT and UPDATE to modify data, CREATE and ALTER to define database structure, and DELETE to remove data. Transactions are managed using commands like COMMIT, ROLLBACK, and SAVEPOINT. Security is enforced using GRANT and REVOKE commands to manage user permissions on database objects.
The document describes various data definition language (DDL) and data manipulation language (DML) commands in MySQL. Some key commands include using CREATE to add new databases, tables, indexes, and constraints. ALTER is used to modify existing database objects. DROP removes databases, tables, columns or indexes. DML commands like SELECT are used to query data, WHERE filters rows, JOIN combines tables, and INSERT, UPDATE, DELETE modify data. COUNT, SUM, DISTINCT and other functions can be used to aggregate or transform result sets.
SQL is a language for communicating with a database management system (DBMS) to carry out tasks like querying data, inserting/updating/deleting rows, and managing database objects. It includes data definition language (DDL) for creating and modifying database objects and data manipulation language (DML) for querying and modifying data. A SQL database contains tables which have a schema defining columns and their data types, and may have constraints. Queries in SQL use SELECT statements to retrieve data that matches conditions specified in the WHERE clause by comparing column values and expressions.
The document discusses the relational model of databases. It defines key concepts like relations, tuples, attributes, domains, and keys. It provides an example database schema for an auction application with relations for owners, items, bids, and buyers. It explains that a relation is a set of tuples with a common schema where each tuple maps attribute names to values from predefined domains. It also defines the different types of keys like superkeys and primary keys.
This document discusses query optimization in database systems. It begins by describing the components of a database management system and how queries are processed. It then explains that the goal of query optimization is to reduce the execution cost of a query by choosing efficient access methods and ordering operations. The document outlines different query plans involving table scans, index scans, and joins. It also introduces concepts like filter factors, statistics about tables and indexes, and how these are used to estimate the cost of alternative query execution plans.
Triggers in SQL allow users to specify actions that are automatically performed in response to insert, update, or delete events on a table. Triggers can be defined to execute before, after, or instead of the triggering event. Triggers have access to old and new values of rows that are inserted, updated, or deleted. Care must be taken with triggers on mutating tables to avoid inconsistent data access or infinite recursion.
This document discusses the entity-relationship (E-R) model for conceptual database design. It defines entities, attributes, relationships and cardinalities. Entities are mapped to relations, with attributes and keys. Relationships are mapped based on cardinality, such as creating a new relation for many-to-many relationships. The document provides examples of mapping auction database entities and relationships to tables. It also covers weak entities, generalization hierarchies, and extensions to the basic relational model.
The document provides an overview and agenda for an SQL programming training, covering SQL fundamentals like data definition, modification, queries, joins, functions and more. It discusses the history and evolution of SQL and how it is used to build, manipulate and access relational databases. Examples are provided throughout to illustrate concepts like different types of queries, joins, functions and other SQL features.
DDL(Data defination Language ) Using OracleFarhan Aslam
The document discusses DDL and DCL commands in Oracle including naming rules for objects, data types, creating tables, constraints, defining constraints, updating and violating constraints, creating tables using subqueries, altering tables, views, sequences, granting and revoking privileges, and dropping tables. It also discusses the Oracle data dictionary.
This document discusses how to create, manage, and modify database tables in Oracle. The key points covered include how to create tables with column definitions and datatypes, alter tables by adding, modifying or dropping columns, rename and truncate tables, and add comments to tables. Operations like create, alter, drop, and truncate allow managing the structure of tables, while comments provide descriptive information.
The document provides an overview of SQL commands and operations including:
1) Creating a database and table, inserting and selecting data, updating records with WHERE clauses.
2) Altering tables by adding or modifying columns and constraints.
3) Different SQL statements like SELECT, INSERT, UPDATE and DELETE and clauses like WHERE are discussed along with syntax and examples.
This slideshow aims to convey the basics of Oracle Database. This slideshow captures all the essential concepts and necessary visualizations to capture all the key concepts of Oracle RDBMS, along with providing all the essential steps to install it on your system, whether it be on Mac or Windows. Capturing all the concepts precisely and cogently, it also explains key concepts like joins in a diagrammatic fashion enabling viewers to visualize them for easier understanding and retention, along with providing them with the syntax to pick up writing simple queries.
This document provides an outline and overview of key concepts in SQL including:
1. Data types that can be used in SQL and considerations when choosing a data type.
2. The two basic classes of SQL - DDL (data definition language) for defining database objects and DML (data manipulation language) for manipulating data.
3. Key DDL operations like CREATE, ALTER, and DROP for creating, modifying and deleting database objects as well as creating primary keys, foreign keys, views and more.
The document provides an overview of SQL and database implementation. It discusses SQL environments, data types, database definition using DDL statements to create tables and views, and DML statements for data manipulation including SELECT, INSERT, UPDATE, DELETE. Examples are provided for each statement type. The SELECT statement is discussed in more depth, with examples demonstrating clauses like WHERE, ORDER BY, GROUP BY, HAVING, functions and operators.
The document provides an overview of key concepts for SQL Server development including:
- Database architecture including files, file groups, and I/O requests
- Performance considerations such as identifying large/heavily accessed tables
- Disaster recovery strategies
- Exploring system databases like master, model, tempdb, and msdb
- Database objects including tables, views, functions, triggers, and transactions
The document also covers database design concepts such as normalization, referential integrity, and strategies to improve database design and performance.
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.
05 Create and Maintain Databases and Tables.pptxMohamedNowfeek1
This document provides an overview of SQL and creating and managing databases and tables in SQL Server 2014. It defines SQL and some common SQL statements used to interact with databases. It then covers creating databases using CREATE DATABASE and creating tables using CREATE TABLE, specifying data types for columns. The document discusses data definition language (DDL) statements for creating, modifying and deleting databases and tables. It provides examples of creating tables with and without attributes like primary keys, foreign keys, check constraints and modifying and deleting tables.
This document provides an overview of MySQL and relational databases. It defines key concepts like databases, tables, rows, columns, primary keys, foreign keys and indexes. It explains how to set up a MySQL database using scripts or a GUI tool. It also covers basic SQL commands like SELECT, INSERT, UPDATE and DELETE and provides examples of their usage. Finally, it introduces the Squirrel SQL Client, an open source Java GUI for interacting with MySQL databases.
The physical data model includes tables, columns, relationships, and database properties to implement the logical data model in a database. It considers performance, indexing, storage, and denormalization. The transformation from logical to physical model imposes database rules, referential integrity, and other aspects. DDL scripts are used to create the required database objects like tables, columns, constraints, indexes, sequences, and triggers.
The physical data model includes tables, columns, relationships, and database properties to implement the logical data model in a database. It considers performance, indexing, storage, and denormalization. The transformation from logical to physical model imposes database rules, referential integrity, and other aspects. DDL scripts are used to create the required database objects like tables, constraints, indexes, sequences, and triggers.
Explained how to the handset on SQL. Explain what is a database. How to create database how to drop database how to create a table. Insert Primary Key, Foreign Key all the constraints, dates. It also explained about the Index.
Data Definition Language (DDL), Data Definition Language (DDL), Data Manipulation Language (DML) , Transaction Control Language (TCL) , Data Control Language (DCL) - , SQL Constraints
[Www.pkbulk.blogspot.com]file and indexingAnusAhmad
The document discusses data storage and indexing in databases. It covers physical and logical addressing of data blocks, main memory addressing when blocks are read into memory, and the I/O model of computation in databases where I/O time dominates. The document also discusses indexing using B+ trees and hash tables, including insertion, deletion, and searching operations in B+ trees. External sorting algorithms are covered, along with how they are optimized when data does not fit in memory.
This document provides an overview of SQL and embedded SQL concepts. It discusses scalar subqueries, embedded SQL programming, transactions, dynamic SQL, and JDBC. Scalar subqueries return single values that can be used in expressions or output clauses. Embedded SQL allows embedding SQL statements in programming languages for connectivity. Transactions define units of work that can be committed or rolled back. Dynamic SQL builds SQL statements dynamically at runtime using strings, while JDBC is the Java database connectivity API.
This document discusses SQL nested queries and aggregation. It provides examples of different types of nested queries using IN, EXISTS, and NOT EXISTS clauses. It explains how to write queries with correlated subqueries that refer to columns in the outer query. It also covers SQL aggregation functions like COUNT, MAX, MIN, SUM, AVG and the GROUP BY clause. It shows how to group query results and apply aggregate functions to each group. The HAVING clause is introduced to filter groups based on aggregate conditions.
JSP (Java Server Pages) Lecture # 9
Java Server Faces the best Alternative of C# and Easy to make your own Application (Desktop applications) or web applications
JSP (Java Server Pages) Lecture # 5
Breif detail lecture about the JSP Servlets with example code the tutorial thing such as how to create, deploy etc etc
This document provides information on Java applets including:
- An applet is a Java program that runs in a web browser context
- It must extend the Applet class or JApplet class
- Includes the applet lifecycle of loading, creating, initializing, starting, stopping, and destroying
- Provides sample code for creating a basic "MyApp" applet class and embedding it in an HTML page
- Discusses restrictions on applets and demonstrates creating an applet project in NetBeans
This document outlines a course on web engineering taught by Imran Daud. It covers topics like HTTP architecture, HTML, Java applets, JSP, Java servlets, and JavaScript. The course marks are distributed as follows: projects/assignments/quizzes 15%, midterm 30%, attendance 5%, and final exam 50%. It also provides information on Java fundamentals like what packages and classes are, how to write, compile, and run a Java program, and an introduction to object-oriented programming concepts in Java.
As of Mid to April Ending, I am building a new Reiki-Yoga Series. No worries, they are free workshops. So far, I have 3 presentations so its a gradual process. If interested visit: https://www.slideshare.net/YogaPrincess
https://ldmchapels.weebly.com
Blessings and Happy Spring. We are hitting Mid Season.
Exploring Substances:
Acidic, Basic, and
Neutral
Welcome to the fascinating world of acids and bases! Join siblings Ashwin and
Keerthi as they explore the colorful world of substances at their school's
National Science Day fair. Their adventure begins with a mysterious white paper
that reveals hidden messages when sprayed with a special liquid.
In this presentation, we'll discover how different substances can be classified as
acidic, basic, or neutral. We'll explore natural indicators like litmus, red rose
extract, and turmeric that help us identify these substances through color
changes. We'll also learn about neutralization reactions and their applications in
our daily lives.
by sandeep swamy
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsDrNidhiAgarwal
Unemployment is a major social problem, by which not only rural population have suffered but also urban population are suffered while they are literate having good qualification.The evil consequences like poverty, frustration, revolution
result in crimes and social disorganization. Therefore, it is
necessary that all efforts be made to have maximum.
employment facilities. The Government of India has already
announced that the question of payment of unemployment
allowance cannot be considered in India
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessMark Soia
Boost your chances of passing the 2V0-11.25 exam with CertsExpert reliable exam dumps. Prepare effectively and ace the VMware certification on your first try
Quality dumps. Trusted results. — Visit CertsExpert Now: https://www.certsexpert.com/2V0-11.25-pdf-questions.html
INTRO TO STATISTICS
INTRO TO SPSS INTERFACE
CLEANING MULTIPLE CHOICE RESPONSE DATA WITH EXCEL
ANALYZING MULTIPLE CHOICE RESPONSE DATA
INTERPRETATION
Q & A SESSION
PRACTICAL HANDS-ON ACTIVITY
How to Subscribe Newsletter From Odoo 18 WebsiteCeline George
Newsletter is a powerful tool that effectively manage the email marketing . It allows us to send professional looking HTML formatted emails. Under the Mailing Lists in Email Marketing we can find all the Newsletter.
Geography Sem II Unit 1C Correlation of Geography with other school subjectsProfDrShaikhImran
The correlation of school subjects refers to the interconnectedness and mutual reinforcement between different academic disciplines. This concept highlights how knowledge and skills in one subject can support, enhance, or overlap with learning in another. Recognizing these correlations helps in creating a more holistic and meaningful educational experience.
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsesushreesangita003
what is pulse ?
Purpose
physiology and Regulation of pulse
Characteristics of pulse
factors affecting pulse
Sites of pulse
Alteration of pulse
for BSC Nursing 1st semester
for Gnm Nursing 1st year
Students .
vitalsign
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 817 from Texas, New Mexico, Oklahoma, and Kansas. 97 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
CURRENT CASE COUNT: 817 (As of 05/3/2025)
• Texas: 688 (+20)(62% of these cases are in Gaines County).
• New Mexico: 67 (+1 )(92.4% of the cases are from Eddy County)
• Oklahoma: 16 (+1)
• Kansas: 46 (32% of the cases are from Gray County)
HOSPITALIZATIONS: 97 (+2)
• Texas: 89 (+2) - This is 13.02% of all TX cases.
• New Mexico: 7 - This is 10.6% of all NM cases.
• Kansas: 1 - This is 2.7% of all KS cases.
DEATHS: 3
• Texas: 2 – This is 0.31% of all cases
• New Mexico: 1 – This is 1.54% of all cases
US NATIONAL CASE COUNT: 967 (Confirmed and suspected):
INTERNATIONAL SPREAD (As of 4/2/2025)
• Mexico – 865 (+58)
‒Chihuahua, Mexico: 844 (+58) cases, 3 hospitalizations, 1 fatality
• Canada: 1531 (+270) (This reflects Ontario's Outbreak, which began 11/24)
‒Ontario, Canada – 1243 (+223) cases, 84 hospitalizations.
• Europe: 6,814
Title: A Quick and Illustrated Guide to APA Style Referencing (7th Edition)
This visual and beginner-friendly guide simplifies the APA referencing style (7th edition) for academic writing. Designed especially for commerce students and research beginners, it includes:
✅ Real examples from original research papers
✅ Color-coded diagrams for clarity
✅ Key rules for in-text citation and reference list formatting
✅ Free citation tools like Mendeley & Zotero explained
Whether you're writing a college assignment, dissertation, or academic article, this guide will help you cite your sources correctly, confidently, and consistent.
Created by: Prof. Ishika Ghosh,
Faculty.
📩 For queries or feedback: [email protected]
1. Views and Constraints in SQL
1
Fall 2001 Database Systems 1
Views
• Views are virtual tables.
– their schema is defined with respect to attributes from other
tables.
– the tuples in a view are derived from base tables using select
statements.
CREATE VIEW itemswithbid (Name, Amount, Date, Buyer)
AS SELECT I.Name, B.Amount, B.Date, Buy.Name
FROM Items I, Bids B, Buyers Buy
WHERE (I.Iid = B.Iid) AND (B.Buyid = Buy.buyid)
Fall 2001 Database Systems 2
Views
• When views are created, their definition is placed in the data
dictionary.
• Views are treated as tables in Select queries.
SELECT I.name, AVG(I.amount)
FROM itemswithbid I
WHERE NOT EXISTS (
SELECT *
FROM itemswithbid I2
WHERE (I.name = I2.name) AND
(I.amount < 25)
GROUP BY I.name
• Views are replaced by their definition from the data dictionary at
query optimization time.
• A query against a view is valid if the view definition can be
expanded to a regular SQL query.
2. Views and Constraints in SQL
2
Fall 2001 Database Systems 3
Views with check option
• Views can be used to insert tuples into the relations they are
derived from.
CREATE VIEW smallbids
AS SELECT * FROM bids
WHERE bids.amount < 20
WITH CHECK OPTION
• The check option is optional and specifies that every row that is
inserted or updated through the view must conform to the definition
of the view.
• Any tuple in the base table that would not be visible through the
view after insert/update cannot be inserted/changed by this view.
• the following update may not work for some tuples:
UPDATE smallbids
SET amount = amount + 10
Fall 2001 Database Systems 4
Updatable views (single table)
1. If a view is defined by a query that contains SET or DISTINCT
operators, a GROUP BY clause, or a group function, then rows
cannot be inserted into, updated in, or deleted from the base
tables using the view.
2. If a view is defined with WITH CHECK OPTION, then a row cannot
be inserted into, or updated in, the base table (using the view), if
the view cannot select the row from the base table.
3. If a NOT NULL column that does not have a DEFAULT clause is
omitted from the view, then a row cannot be inserted into the base
table using the view.
4. If the view was created by using an expression, such as
DECODE(deptno, 10, "SALES", ...), then rows cannot be inserted
into or updated in the base table using the view.
3. Views and Constraints in SQL
3
Fall 2001 Database Systems 5
Updatable views (join table)
A modifiable join view is a view that contains more than one table in the
top-level FROM clause of the SELECT statement, and that does
not contain any of the following:
• DISTINCT operator
• Aggregate functions: AVG, COUNT, GLB, MAX, MIN, STDDEV,
SUM, or VARIANCE
• Set operations: UNION, UNION ALL, INTERSECT, MINUS
• GROUP BY or HAVING clauses
• START WITH or CONNECT BY clauses
• ROWNUM pseudocolumn
A further restriction on which join views are modifiable is that if a view is
a join on other nested views, then the other nested views must be
mergeable into the top level view.
Finally, the joined tables should be key-preserving.
Fall 2001 Database Systems 6
Updateable views (key
preservation)
• Let V be a view involving relations R and S.
• The key for R (or S) is said to be preserved in V, if the
key for R is a key for V.
– Remember, no two tuples can have the same key value and
different values for other attributes
– After a join, the “key” property may be propagated to the new
attributes
– Even if the key for R is not in the view attributes, the key property
may still be maintained.
4. Views and Constraints in SQL
4
Fall 2001 Database Systems 7
Key preservation
CREATE TABLE Dept_tab (
Deptno NUMBER(4) PRIMARY KEY,
Dname VARCHAR2(14),
Loc VARCHAR2(13));
CREATE TABLE Emp_tab (
Empno NUMBER(4) PRIMARY KEY,
Ename VARCHAR2(10),
Job varchar2(9),
Mgr NUMBER(4),
Hiredate DATE,
Sal NUMBER(7,2),
Comm NUMBER(7,2),
Deptno NUMBER(2),
FOREIGN KEY (Deptno)
REFERENCES Dept_tab(Deptno));
CREATE VIEW Emp_dept_view AS
SELECT e.Empno, e.Ename, e.Deptno,
e.Sal, d.Dname, d.Loc
FROM Emp_tab e, Dept_tab d
WHERE e.Deptno = d.Deptno AND
d.Loc IN ('DALLAS', 'NEW YORK',
'BOSTON');
Is the key for relation Emp_tab preserved?
Is the key for relation Dept_tab preserved?
Fall 2001 Database Systems 8
Views
• Value of views
– Views can be used as short cuts to
commonly asked complex queries.
– Views provide windows to the database,
allowing different users to view the same
data differently.
– Views make it possible to define security and
access control mechanisms at a finer
granularity than possible with tables.
5. Views and Constraints in SQL
5
Fall 2001 Database Systems 9
Views – side note
• Pseudo-columns are system variables that can
be queried as if they are actual columns
• All tables have the same pseudo-columns,
attached to every tuple in the table
• Examples:
– ROWID: the identifier of the physical location of the
tuple
– USER: the identifier of the current user accessing the
table (like the whois command in Unix)
Fall 2001 Database Systems 10
CREATE TABLE Owners (
Oid INTEGER PRIMARY KEY,
OName VARCHAR2(40),
Ouser VARCHAR2(40)
) ;
CREATE TABLE items (
Iid INTEGER PRIMARY KEY,
IName VARCHAR2(40),
Oid INT,
FOREIGN KEY Oid REFERENCES
Owners(Oid)
) ;
INSERT INTO Owners VALUES(1,’Sibel
Adali’, ‘ADALIS’) ;
INSERT INTO Owners VALUES(2, ‘David
Spooner’, ‘SPOOND’) ;
CREATE VIEW ownItems AS
SELECT I.Iid, I.Iname
FROM Items I, Owner O
WHERE I.Oid = O.Oid AND
O.Ouser = USER ;
6. Views and Constraints in SQL
6
Fall 2001 Database Systems 11
DROP Command
• Any table/view can be removed from the database using
DROP TABLE/VIEW command.
• If a view is dropped, then its description is removed from
the database.
• If a table is dropped, then all the data it contains is also
removed.
• Dropping a table may invalidate the existing views on this
table.
Fall 2001 Database Systems 12
Key and Unique Constraints
• The primary key and the unique constraint specify a set of attributes
that will be unique for all tuples
– a table may have many unique constraints
– a table may have at most one primary key
– a foreign key can refer only to a primary key
– primary key or unique constraints should be checked for every
update/insert
– if an update/insert violates a constraint, it is rejected!
some systems will not check these constraints unless an index
exists
CREATE UNIQUE KEY INDEX studentid ON student(sid)
7. Views and Constraints in SQL
7
Fall 2001 Database Systems 13
Alternate forms
CREATE TABLE student
( sid INTEGER
PRIMARY KEY,
lastname VARCHAR(30),
firstname VARCHAR(30),
major CHAR(4)
DEFAULT ‘None’,
email CHAR(255) UNIQUE,
entrydate DATE
DEFAULT SYSDATE,
gpa NUMBER(5,2),
total_credits INTEGER,
probation_date DATE,
UNIQUE(lastname, firstname,
major)
)
CREATE TABLE course
( course_number INTEGER,
dept_id INTEGER,
course_name VARCHAR(30),
PRIMARY KEY(course_number,
dept_id)
)
Fall 2001 Database Systems 14
Name all your contraints
CREATE TABLE student
( sid INTEGER,
lastname VARCHAR(30),
firstname VARCHAR(30),
major CHAR(4) DEFAULT ‘None’,
email CHAR(255),
entrydate DATE DEFAULT SYSDATE,
gpa NUMBER(5,2),
total_credits INTEGER,
probation_date DATE,
CONSTRAINT student_pk PRIMARY KEY (sid),
CONSTRAINT unique_lfm UNIQUE(lastname, firstname, major)
CONSTRAINT unique_email UNIQUE(email)
)
8. Views and Constraints in SQL
8
Fall 2001 Database Systems 15
Referential integrity
• A table T1 may reference the tuples in another table T2 using a foreign
key declaration
– all attributes in T2’s primary key must be referenced in T1
– if T1(A) references T2(B), then each tuple in T1 either has a primary
key value from T2(B) or the null value in A
CREATE TABLE section (
section_id INTEGER PRIMARY KEY,
section_number INTEGER NOT NULL,
course_number INTEGER NOT NULL,
dept_id INTEGER,
semester CHAR(8),
instructor_id INTEGER REFERENCES instructor(id),
FOREIGN KEY (course_number, dept_id)
REFERENCES course(course_number, dept_id)
)
Fall 2001 Database Systems 16
Maintaining referential integrity
• Suppose T1(A) references T2(B)
– insert tuple into T1 with non-null A -- if T2 has no tuple such that
T1(A) = T2(B), reject the insertion
– change value of A in tuple in T1 -- if T2 has no tuple such that
T1(A) = T2(B) for new value of A, reject the update
– delete tuple from T2 -- if a tuple in T1 references the deleted
tuple:
• reject the delete (default action)
• delete the tuple in T1 (known as a cascade delete)
• set A in the T1 tuple to null (known as set null option)
– change value of T2(B) in a tuple -- same as above
9. Views and Constraints in SQL
9
Fall 2001 Database Systems 17
Maintaining referential integrity
CREATE TABLE section (
section_id INTEGER PRIMARY KEY,
section_number INTEGER NOT NULL,
course_number INTEGER NOT NULL,
dept_id INTEGER,
semester CHAR(10),
instructor_id INTEGER ,
FOREIGN KEY(instructor_id)
REFERENCES instructor(id)
ON DELETE SET NULL
ON UPDATE CASCADE,
FOREIGN KEY (course_number, dept_id)
REFERENCES course(course_number, dept_id)
ON UPDATE CASCADE
)
Fall 2001 Database Systems 18
Constraints on attribute values
• NOT NULL -- attribute may not have a null value for any tuple
• CHECK -- limit the values a specific attribute may have
CREATE TABLE section (
…
semester CHAR(10)
CHECK ((semester like ‘Spring_’) or (semester like ‘Fall_’) or
(semester like ‘Summer_I’) or (semester like ‘Summer_II’))
)
CREATE TABLE student (
…
gender CHAR(1)
CHECK (gender IN (‘F’ , ‘M’)),
totalcredits INTEGER
CHECK ((totalcredits > 0) AND (totalcredits < 200))
)
10. Views and Constraints in SQL
10
Fall 2001 Database Systems 19
Check constraint
• If a check constraint involves a comparison with other relations, then
a select statement is needed
• Check is only checked when a tuple is inserted/updated
• Example: Instructors in the section relation must be from the Troy
campus
CREATE TABLE section (
…
instructor_id INTEGER
CHECK (instructor_id IN
(SELECT id FROM instructor, department
WHERE (instructor.dept_id = department.dept_id) AND
(department.address LIKE ‘*Troy*’) ))
)
Fall 2001 Database Systems 20
Using Domains
• It is possible to create your own domains and use them
in creating tables
CREATE DOMAIN SemesterD CHAR(10)
CHECK ((VALUE like ‘Spring__’) or
(VALUE like ‘Fall__’) or
(VALUE like ‘Summer__I’) or
(VALUE like ‘Summer__II’))
CREATE TABLE section (
…
semester SemesterD
)
11. Views and Constraints in SQL
11
Fall 2001 Database Systems 21
General tuple-based constraints
• Check can be used for constraints on multiple
attributes in a relation
• Example: A section must have either a non-
null department id or instructor id at all times
CREATE TABLE section (
…
CHECK (instructor_id NOT NULL OR
section_number NOT NULL)
)
Fall 2001 Database Systems 22
Exercises
• Create the following constraints:
1. section -- the semester has to be fall or spring, and years
can be only between 1980 and 1999
2. student -- the gpa of a a student cannot fall below 0.0 and
cannot go above 4.0
semester CHAR(10)
CHECK ((semester=‘Fall’ OR semester=‘Spring’)
AND year>1980 AND year<1999 )
gpa number(5,2) CHECK ((gpa >= 0.0) AND (gpa <= 4.0))
12. Views and Constraints in SQL
12
Fall 2001 Database Systems 23
lastname VARCHAR(30)
CHECK (length(lastname) > 4 AND
(lastname LIKE ‘%a%’ OR lastname LIKE ‘%e%’ OR
lastname LIKE ‘%i%’ OR lastname LIKE ‘%o%’ OR
lastname LIKE ‘%u%’ ) )
Exercises
3. student -- the grade in the transcript relation can only be one of
‘A’,’B’,’C’,’D’ or ‘F’
4. instructor -- instructors cannot have last names with less than
five letters and their last names should contain some vowels.
grade CHAR(1) CHECK (grade in (‘A’,’B’,’C’,’D’,’F’))
Fall 2001 Database Systems 24
Assertions
• Assertions are more general forms of constraints that
apply to tuples, sets of tables and a database in general.
CREATE ASSERTION assertion_name
CHECK where_clause
• Example: The total number of students in the ‘CS’ major
cannot exceed 400!
CREATE ASSERTION limitcs
CHECK (400 >= (SELECT count(*) FROM student
WHERE major = ‘CS’) );
Anything you would put in a
where clause goes in here
13. Views and Constraints in SQL
13
Fall 2001 Database Systems 25
Assertions
• No student can take two different sections of
the same course in the same semester!
CREATE ASSERTION no2sections
CHECK (NOT EXISTS (
SELECT t.sid, s.semester,
s.course_number, s.dept_id
FROM section s, transcript t
WHERE s.section_id = t.section_id
GROUP BY t.sid, s.semester,
s.course_number, s.dept_id
HAVING count(s.section_number) > 1)) ;
Fall 2001 Database Systems 26
Assertions
• If a students GPA is greater then 2.0, then she/he cannot be
on probation.
CREATE ASSERTION onprobation
CHECK (NOT EXISTS (
SELECT * FROM student
WHERE student.gpa > 2.0 AND
probation_date NOT NULL)) ;
Equivalent to:
CREATE TABLE student (
…
CHECK (student.gpa < 2.0 or probation_date NULL)
)
15. Views and Constraints in SQL
15
Fall 2001 Database Systems 29
Database for Exercises
student(sid, lastname, firstname, major, entrydate, gpa,
total_credits, probation_date)
course(course_number, dept_id, course_name)
department(dept_id, department_name, abbreviation,
address)
instructor(instructor_id, firstname, lastname, dept_id, rank,
salary)
section(section_id, section_number, course_number,
dept_id, semester, instructor_id)
transcript(sid, section_id, credits, grade)
requirement(req_id, major, course_number, dept_id)
Fall 2001 Database Systems 30
Exercises
Write the following assertion for this database:
1. A student’s major is either “NONE” or one of the
department abbreviations.
CREATE ASSERTION a1
CHECK (NOT EXISTS (
SELECT * FROM student
WHERE (student.major ‘NONE’) AND
(student.major NOT IN
(SELECT abbreviation FROM department)))) ;
16. Views and Constraints in SQL
16
Fall 2001 Database Systems 31
Exercises
Write the following assertion for this database:
2. The total number of requirements for a major cannot
exceed 16 courses.
CREATE ASSERTION a2 CHECK
(NOT EXISTS (
SELECT major FROM requirement
GROUP BY major
HAVING count(*) 16 )) ;
Fall 2001 Database Systems 32
Exercises
Write the following assertion for this database:
3. The salary of an instructor cannot be greater than that of
another instructor in the same department with higher rank
(assume rank is an integer, high rank means high number)
CREATE ASSERTION a3
CHECK (NOT EXISTS (
SELECT * FROM instructor I
WHERE EXISTS (
SELECT * FROM instructor I2
WHERE I1.dept_id = I2.dept_id AND
I1.rank I2.rank AND
I1.salary I2.salary ))
17. Views and Constraints in SQL
17
Fall 2001 Database Systems 33
Exercises
Write the following assertion for this database:
4. The total number of credits for a student (in the student
table) is equal to the total number of credits in the
transcript.
CREATE ASSERTION a4
CHECK (NOT EXISTS (
SELECT * FROM student S
WHERE S.totalcredits
(SELECT sum(T.credits)
FROM transcript T
WHERE T.sid = S.sid)))
What if the student took the same course twice?
Fall 2001 Database Systems 34
Exercise 4 Correct Solution
• We will use the grade for the last section of any course the student
took (highest section id).
CREATE ASSERTION a4
CHECK (NOT EXISTS (
SELECT * FROM student S
WHERE S.totalcredits
(SELECT sum(T1.credits)
FROM transcript T1, section Sc1
WHERE (T1.sid = S.sid) AND
(Sc1.section_id = T1.section_id) AND NOT EXISTS
(SELECT * FROM transcript T2, section Sc2
WHERE (Sc2.section_id = T2.section_id) AND
(Sc1.course_number = Sc2.course_number) AND
(Sc1.dept_id = Sc2.dept_id) AND
(T2.sid = S.sid) AND
(T1.section_id T2.section_id) ) ) ) )