This document provides an overview of the SQL schema definition, data definition, data types, constraints, queries, DML statements, joins, and aggregation in SQL. It begins with an introduction to creating SQL schemas and defining tables, data types, and constraints. It then covers basic retrieval queries using SELECT statements, additional query features, DML statements for data modification, joined tables and outer joins, and aggregation with functions. Examples are provided throughout to illustrate each SQL concept and feature.
The document discusses SQL commands for schema definition, constraints, and queries. It covers using CREATE TABLE to define tables and columns, including data types and constraints like PRIMARY KEY and FOREIGN KEY. ALTER TABLE is used to modify existing tables. DROP TABLE removes tables. Queries use SELECT to retrieve data that matches conditions in the WHERE clause. Joins and aliases are discussed. Additional data types like DATE and TIMESTAMP are introduced in later SQL standards.
This chapter discusses SQL concepts for defining schemas, constraints, and queries/views. It covers using SQL commands like CREATE TABLE, ALTER TABLE, and DROP TABLE to define and modify table schemas. Constraints like primary keys, foreign keys, and referential integrity options are defined. The chapter also discusses the basic SELECT query syntax and concepts like aliases, joins, and nested queries.
The document discusses the EXISTS function in SQL, which checks if the result of a correlated nested query is empty or not. It provides an example query (Q16B) that uses EXISTS to retrieve the names of employees who have a dependent with the same first name, sex, and social security number. The document also explains how EXISTS and NOT EXISTS work and provides additional example queries using these functions.
SQL is a standard language for querying and manipulating data in relational database management systems. This document provides an introduction to SQL, including how to define database schemas with tables, constraints, and data types. It also covers basic SQL queries using operators like SELECT, FROM, WHERE, and JOIN to retrieve and combine data from one or more tables. More advanced topics covered include set operations, correlated subqueries, and handling null values.
SQL is a language used for managing data in relational database management systems. The core SQL statements are used for data definition, queries, and updates. The CREATE statement is used to define tables and other schema objects. Tables have attributes with specified data types. Constraints like primary keys, unique keys, foreign keys, checks, and defaults can be defined. The SELECT statement is used to query data using projections, selections from tables using a FROM clause and optional WHERE clause. Data can be inserted, updated, and deleted using the INSERT, UPDATE, and DELETE statements respectively. Views provide virtual tables derived from other base tables.
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
Common table expressions (CTEs) allow users to define temporary result sets within a single SQL statement that can be referenced within that statement, making complex queries easier to read and maintain by breaking them down into simpler components, while subqueries return data from a nested SQL query to filter the results of the outer query. Joins combine data from two or more tables by linking common columns between them and come in various types like inner, left, right, full, and cross joins.
This document provides an overview of SQL (Structured Query Language). It discusses SQL functions including data manipulation language (DML) and data definition language (DDL). DML commands like SELECT, UPDATE, DELETE and INSERT are covered. The SELECT statement syntax and use of clauses like WHERE, ORDER BY, GROUP BY and JOINs are explained. Aggregate functions like COUNT, AVG, SUM etc and scalar functions are also summarized. Examples are provided throughout to illustrate the concepts and syntax.
This document provides an introduction to SQL (Structured Query Language). SQL is a language used to define, query, modify, and control relational databases. The document outlines the main SQL commands for data definition (CREATE, ALTER, DROP), data manipulation (INSERT, UPDATE, DELETE), and data control (GRANT, REVOKE). It also discusses SQL data types, integrity constraints, and how to use SELECT statements to query databases using projections, selections, comparisons, logical conditions, and ordering. The FROM clause is introduced as specifying the relations involved in a query.
The document discusses SQL commands for schema definition, constraints, and queries. It covers using CREATE TABLE to define tables and columns, including data types and constraints like PRIMARY KEY and FOREIGN KEY. ALTER TABLE is used to modify existing tables. DROP TABLE removes tables. Queries use SELECT to retrieve data that matches conditions in the WHERE clause. Joins and aliases are discussed. Additional data types like DATE and TIMESTAMP are introduced in later SQL standards.
This chapter discusses SQL concepts for defining schemas, constraints, and queries/views. It covers using SQL commands like CREATE TABLE, ALTER TABLE, and DROP TABLE to define and modify table schemas. Constraints like primary keys, foreign keys, and referential integrity options are defined. The chapter also discusses the basic SELECT query syntax and concepts like aliases, joins, and nested queries.
The document discusses the EXISTS function in SQL, which checks if the result of a correlated nested query is empty or not. It provides an example query (Q16B) that uses EXISTS to retrieve the names of employees who have a dependent with the same first name, sex, and social security number. The document also explains how EXISTS and NOT EXISTS work and provides additional example queries using these functions.
SQL is a standard language for querying and manipulating data in relational database management systems. This document provides an introduction to SQL, including how to define database schemas with tables, constraints, and data types. It also covers basic SQL queries using operators like SELECT, FROM, WHERE, and JOIN to retrieve and combine data from one or more tables. More advanced topics covered include set operations, correlated subqueries, and handling null values.
SQL is a language used for managing data in relational database management systems. The core SQL statements are used for data definition, queries, and updates. The CREATE statement is used to define tables and other schema objects. Tables have attributes with specified data types. Constraints like primary keys, unique keys, foreign keys, checks, and defaults can be defined. The SELECT statement is used to query data using projections, selections from tables using a FROM clause and optional WHERE clause. Data can be inserted, updated, and deleted using the INSERT, UPDATE, and DELETE statements respectively. Views provide virtual tables derived from other base tables.
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
Common table expressions (CTEs) allow users to define temporary result sets within a single SQL statement that can be referenced within that statement, making complex queries easier to read and maintain by breaking them down into simpler components, while subqueries return data from a nested SQL query to filter the results of the outer query. Joins combine data from two or more tables by linking common columns between them and come in various types like inner, left, right, full, and cross joins.
This document provides an overview of SQL (Structured Query Language). It discusses SQL functions including data manipulation language (DML) and data definition language (DDL). DML commands like SELECT, UPDATE, DELETE and INSERT are covered. The SELECT statement syntax and use of clauses like WHERE, ORDER BY, GROUP BY and JOINs are explained. Aggregate functions like COUNT, AVG, SUM etc and scalar functions are also summarized. Examples are provided throughout to illustrate the concepts and syntax.
This document provides an introduction to SQL (Structured Query Language). SQL is a language used to define, query, modify, and control relational databases. The document outlines the main SQL commands for data definition (CREATE, ALTER, DROP), data manipulation (INSERT, UPDATE, DELETE), and data control (GRANT, REVOKE). It also discusses SQL data types, integrity constraints, and how to use SELECT statements to query databases using projections, selections, comparisons, logical conditions, and ordering. The FROM clause is introduced as specifying the relations involved in a query.
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
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 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 various SQL integrity constraints and authorization commands. It describes primary key, foreign key, not null, check, unique, and default constraints that can be applied during table creation. It also covers the GRANT and REVOKE commands used to manage user permissions to tables. Examples are provided for each constraint and command to illustrate their proper syntax.
SQL was designed at IBM Research to be a comprehensive database language for data definition, queries, and updates of relational databases. It uses terms like table, row, and column. The main command for data definition is CREATE, which can be used to create schemas, tables, domains, views, and other elements. Schemas group database objects and provide a namespace. A catalog is a collection of schemas. Integrity constraints like referential integrity are defined between relations within the same schema and catalog.
Structured Query Language (SQL) is used to define, manipulate, and control data in a relational database. The document provides an overview of SQL, covering its main components like Data Definition Language (DDL) for defining tables, Data Manipulation Language (DML) for inserting, updating, deleting and selecting data, and Data Control Language (DCL) for controlling database privileges. It describes the basic DML commands, discusses integrity constraints and transactions, and shows how to perform single table and joined queries using SQL syntax.
This document provides an overview of SQL (Structured Query Language) including key statements and concepts. It discusses the different types of SQL statements including DDL for definitions, DML for data manipulation, and DCL for access control. It also summarizes important SQL statements and clauses like SELECT, INSERT, UPDATE, DELETE, WHERE, GROUP BY, HAVING, ORDER BY and more. The document is intended as an introduction to the SQL language and relational database concepts.
This document provides an overview of structured query language (SQL) including the different types of SQL commands, how to manipulate data using SQL statements like INSERT, UPDATE, DELETE, and SELECT, and how to retrieve data from single and multiple tables using joins and subqueries. Key topics covered include data definition language (DDL) to define databases, data manipulation language (DML) to query and modify data, and data control language (DCL) to administer database privileges. The document explains SQL concepts like integrity constraints, transactions, and aliases as well as syntax for common queries.
This document provides an overview of structured query language (SQL) including the different types of SQL commands, how to manipulate data using SQL statements like INSERT, UPDATE, DELETE, and SELECT, and how to retrieve data from single and multiple tables using joins and subqueries. Key topics covered include data definition language (DDL) to define databases, data manipulation language (DML) to query and modify data, and data control language (DCL) to administer database privileges. The document explains SQL concepts like integrity constraints, transactions, and aliases as well as syntax for common queries.
This document discusses advances in SQL queries, including more complex retrieval queries using NULL values and three-valued logic, nested/subqueries using operators like IN and EXISTS, and group functions like COUNT and AVG. It also covers JOINs like inner, outer, full and equi joins used to combine data from multiple tables based on join conditions between columns.
Database questions and answers document containing:
1. SQL queries for fetching data from tables using SELECT and WHERE clauses.
2. Joins to retrieve data from multiple tables using SELECT, FROM, and WHERE clauses.
3. Differences between unique key and primary key including allowing null values and number allowed per table.
4. Uses and types of indexes to improve query performance including on single or multiple columns.
5. Purpose and examples of foreign key constraints to maintain referential integrity.
6. Aggregate functions like AVG, COUNT, MAX used in 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 provides an overview of SQL data definition and integrity constraints. It discusses:
1) SQL data types and integrity constraints such as required fields, domain constraints, entity integrity, referential integrity, and general constraints. It provides examples of defining these constraints using SQL.
2) SQL DDL statements for creating, altering and dropping schemas, domains, tables, views and other database objects. Examples are provided for creating tables with constraints and altering tables.
3) Views - how they provide a dynamic result set defined by a query. The document describes creating, dropping and resolving views in SQL. Examples include horizontal, vertical and grouped/joined views.
The document provides an introduction to the SQL language, including its main components of DML (Data Manipulation Language) and DDL (Data Definition Language). It discusses SQL concepts such as creating tables with data types, defining primary and foreign keys, and using basic queries with SELECT, FROM, WHERE and ORDER BY clauses.
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.
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.
The document discusses various SQL modification commands including INSERT, DELETE, UPDATE, and SELECT. It explains that INSERT adds rows to a table, DELETE removes rows, and UPDATE modifies existing rows. It provides syntax examples for each command. Integrity constraints like PRIMARY KEY, UNIQUE, and NOT NULL are also covered to ensure data consistency. The SELECT command is used to retrieve data from one or more tables, and can include a WHERE clause to filter rows and an ORDER BY clause to sort the results.
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.
2. DBMS Experiment - Lab 2 Made in SQL UsedTheVerse1
The document describes a database management system lab covering integrity constraints and data manipulation language (DML). It defines various integrity constraints like primary key, unique key, foreign key, check, default and NOT NULL constraints. It also explains how to create tables, alter tables, insert, update and delete data using DML commands. Experiments are described to design tables for different systems using appropriate integrity constraints and populate them with sample data using DML statements.
Enhanced data collection methods can help uncover the true extent of child abuse and neglect. This includes Integrated Data Systems from various sources (e.g., schools, healthcare providers, social services) to identify patterns and potential cases of abuse and neglect.
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
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 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 various SQL integrity constraints and authorization commands. It describes primary key, foreign key, not null, check, unique, and default constraints that can be applied during table creation. It also covers the GRANT and REVOKE commands used to manage user permissions to tables. Examples are provided for each constraint and command to illustrate their proper syntax.
SQL was designed at IBM Research to be a comprehensive database language for data definition, queries, and updates of relational databases. It uses terms like table, row, and column. The main command for data definition is CREATE, which can be used to create schemas, tables, domains, views, and other elements. Schemas group database objects and provide a namespace. A catalog is a collection of schemas. Integrity constraints like referential integrity are defined between relations within the same schema and catalog.
Structured Query Language (SQL) is used to define, manipulate, and control data in a relational database. The document provides an overview of SQL, covering its main components like Data Definition Language (DDL) for defining tables, Data Manipulation Language (DML) for inserting, updating, deleting and selecting data, and Data Control Language (DCL) for controlling database privileges. It describes the basic DML commands, discusses integrity constraints and transactions, and shows how to perform single table and joined queries using SQL syntax.
This document provides an overview of SQL (Structured Query Language) including key statements and concepts. It discusses the different types of SQL statements including DDL for definitions, DML for data manipulation, and DCL for access control. It also summarizes important SQL statements and clauses like SELECT, INSERT, UPDATE, DELETE, WHERE, GROUP BY, HAVING, ORDER BY and more. The document is intended as an introduction to the SQL language and relational database concepts.
This document provides an overview of structured query language (SQL) including the different types of SQL commands, how to manipulate data using SQL statements like INSERT, UPDATE, DELETE, and SELECT, and how to retrieve data from single and multiple tables using joins and subqueries. Key topics covered include data definition language (DDL) to define databases, data manipulation language (DML) to query and modify data, and data control language (DCL) to administer database privileges. The document explains SQL concepts like integrity constraints, transactions, and aliases as well as syntax for common queries.
This document provides an overview of structured query language (SQL) including the different types of SQL commands, how to manipulate data using SQL statements like INSERT, UPDATE, DELETE, and SELECT, and how to retrieve data from single and multiple tables using joins and subqueries. Key topics covered include data definition language (DDL) to define databases, data manipulation language (DML) to query and modify data, and data control language (DCL) to administer database privileges. The document explains SQL concepts like integrity constraints, transactions, and aliases as well as syntax for common queries.
This document discusses advances in SQL queries, including more complex retrieval queries using NULL values and three-valued logic, nested/subqueries using operators like IN and EXISTS, and group functions like COUNT and AVG. It also covers JOINs like inner, outer, full and equi joins used to combine data from multiple tables based on join conditions between columns.
Database questions and answers document containing:
1. SQL queries for fetching data from tables using SELECT and WHERE clauses.
2. Joins to retrieve data from multiple tables using SELECT, FROM, and WHERE clauses.
3. Differences between unique key and primary key including allowing null values and number allowed per table.
4. Uses and types of indexes to improve query performance including on single or multiple columns.
5. Purpose and examples of foreign key constraints to maintain referential integrity.
6. Aggregate functions like AVG, COUNT, MAX used in 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 provides an overview of SQL data definition and integrity constraints. It discusses:
1) SQL data types and integrity constraints such as required fields, domain constraints, entity integrity, referential integrity, and general constraints. It provides examples of defining these constraints using SQL.
2) SQL DDL statements for creating, altering and dropping schemas, domains, tables, views and other database objects. Examples are provided for creating tables with constraints and altering tables.
3) Views - how they provide a dynamic result set defined by a query. The document describes creating, dropping and resolving views in SQL. Examples include horizontal, vertical and grouped/joined views.
The document provides an introduction to the SQL language, including its main components of DML (Data Manipulation Language) and DDL (Data Definition Language). It discusses SQL concepts such as creating tables with data types, defining primary and foreign keys, and using basic queries with SELECT, FROM, WHERE and ORDER BY clauses.
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.
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.
The document discusses various SQL modification commands including INSERT, DELETE, UPDATE, and SELECT. It explains that INSERT adds rows to a table, DELETE removes rows, and UPDATE modifies existing rows. It provides syntax examples for each command. Integrity constraints like PRIMARY KEY, UNIQUE, and NOT NULL are also covered to ensure data consistency. The SELECT command is used to retrieve data from one or more tables, and can include a WHERE clause to filter rows and an ORDER BY clause to sort the results.
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.
2. DBMS Experiment - Lab 2 Made in SQL UsedTheVerse1
The document describes a database management system lab covering integrity constraints and data manipulation language (DML). It defines various integrity constraints like primary key, unique key, foreign key, check, default and NOT NULL constraints. It also explains how to create tables, alter tables, insert, update and delete data using DML commands. Experiments are described to design tables for different systems using appropriate integrity constraints and populate them with sample data using DML statements.
Enhanced data collection methods can help uncover the true extent of child abuse and neglect. This includes Integrated Data Systems from various sources (e.g., schools, healthcare providers, social services) to identify patterns and potential cases of abuse and neglect.
Did you know that drowning is a leading cause of unintentional death among young children? According to recent data, children aged 1-4 years are at the highest risk. Let's raise awareness and take steps to prevent these tragic incidents. Supervision, barriers around pools, and learning CPR can make a difference. Stay safe this summer!
End-to-end pipeline agility - Berlin Buzzwords 2024Lars Albertsson
We describe how we achieve high change agility in data engineering by eliminating the fear of breaking downstream data pipelines through end-to-end pipeline testing, and by using schema metaprogramming to safely eliminate boilerplate involved in changes that affect whole pipelines.
A quick poll on agility in changing pipelines from end to end indicated a huge span in capabilities. For the question "How long time does it take for all downstream pipelines to be adapted to an upstream change," the median response was 6 months, but some respondents could do it in less than a day. When quantitative data engineering differences between the best and worst are measured, the span is often 100x-1000x, sometimes even more.
A long time ago, we suffered at Spotify from fear of changing pipelines due to not knowing what the impact might be downstream. We made plans for a technical solution to test pipelines end-to-end to mitigate that fear, but the effort failed for cultural reasons. We eventually solved this challenge, but in a different context. In this presentation we will describe how we test full pipelines effectively by manipulating workflow orchestration, which enables us to make changes in pipelines without fear of breaking downstream.
Making schema changes that affect many jobs also involves a lot of toil and boilerplate. Using schema-on-read mitigates some of it, but has drawbacks since it makes it more difficult to detect errors early. We will describe how we have rejected this tradeoff by applying schema metaprogramming, eliminating boilerplate but keeping the protection of static typing, thereby further improving agility to quickly modify data pipelines without fear.
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...Kaxil Naik
Navigating today's data landscape isn't just about managing workflows; it's about strategically propelling your business forward. Apache Airflow has stood out as the benchmark in this arena, driving data orchestration forward since its early days. As we dive into the complexities of our current data-rich environment, where the sheer volume of information and its timely, accurate processing are crucial for AI and ML applications, the role of Airflow has never been more critical.
In my journey as the Senior Engineering Director and a pivotal member of Apache Airflow's Project Management Committee (PMC), I've witnessed Airflow transform data handling, making agility and insight the norm in an ever-evolving digital space. At Astronomer, our collaboration with leading AI & ML teams worldwide has not only tested but also proven Airflow's mettle in delivering data reliably and efficiently—data that now powers not just insights but core business functions.
This session is a deep dive into the essence of Airflow's success. We'll trace its evolution from a budding project to the backbone of data orchestration it is today, constantly adapting to meet the next wave of data challenges, including those brought on by Generative AI. It's this forward-thinking adaptability that keeps Airflow at the forefront of innovation, ready for whatever comes next.
The ever-growing demands of AI and ML applications have ushered in an era where sophisticated data management isn't a luxury—it's a necessity. Airflow's innate flexibility and scalability are what makes it indispensable in managing the intricate workflows of today, especially those involving Large Language Models (LLMs).
This talk isn't just a rundown of Airflow's features; it's about harnessing these capabilities to turn your data workflows into a strategic asset. Together, we'll explore how Airflow remains at the cutting edge of data orchestration, ensuring your organization is not just keeping pace but setting the pace in a data-driven future.
Session in https://budapestdata.hu/2024/04/kaxil-naik-astronomer-io/ | https://dataml24.sessionize.com/session/667627
We are pleased to share with you the latest VCOSA statistical report on the cotton and yarn industry for the month of May 2024.
Starting from January 2024, the full weekly and monthly reports will only be available for free to VCOSA members. To access the complete weekly report with figures, charts, and detailed analysis of the cotton fiber market in the past week, interested parties are kindly requested to contact VCOSA to subscribe to the newsletter.
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Aggregage
This webinar will explore cutting-edge, less familiar but powerful experimentation methodologies which address well-known limitations of standard A/B Testing. Designed for data and product leaders, this session aims to inspire the embrace of innovative approaches and provide insights into the frontiers of experimentation!
Codeless Generative AI Pipelines
(GenAI with Milvus)
https://ml.dssconf.pl/user.html#!/lecture/DSSML24-041a/rate
Discover the potential of real-time streaming in the context of GenAI as we delve into the intricacies of Apache NiFi and its capabilities. Learn how this tool can significantly simplify the data engineering workflow for GenAI applications, allowing you to focus on the creative aspects rather than the technical complexities. I will guide you through practical examples and use cases, showing the impact of automation on prompt building. From data ingestion to transformation and delivery, witness how Apache NiFi streamlines the entire pipeline, ensuring a smooth and hassle-free experience.
Timothy Spann
https://www.youtube.com/@FLaNK-Stack
https://medium.com/@tspann
https://www.datainmotion.dev/
milvus, unstructured data, vector database, zilliz, cloud, vectors, python, deep learning, generative ai, genai, nifi, kafka, flink, streaming, iot, edge
Open Source Contributions to Postgres: The Basics POSETTE 2024ElizabethGarrettChri
Postgres is the most advanced open-source database in the world and it's supported by a community, not a single company. So how does this work? How does code actually get into Postgres? I recently had a patch submitted and committed and I want to share what I learned in that process. I’ll give you an overview of Postgres versions and how the underlying project codebase functions. I’ll also show you the process for submitting a patch and getting that tested and committed.
Open Source Contributions to Postgres: The Basics POSETTE 2024
UNIT-3.pptx
1. DATABASE MANAGEMENT SYSTEMS
UNIT-3
Syllabus:-
SQL Schema Definition, SQL Data Definition and Data Types , Specifying constraints
in SQL, Basic retrieval queries in SQL, Additional features of SQL ,More complex
SQL Queries, Insert, Delete and Update statements in SQL, Joined Tables in SQL
and Outer Joins, Aggregate functions , The GROUP BY and HAVING Clauses,
Specifying Constraints as Assertions and Triggers, Views (Virtual Tables) in SQL,
Schema Change Statement in SQL.
1
2. 2
SQL Data Definition and Data Types
An SQL schema is identified by a schema name and includes an
authorization identifier to indicate the user or account who owns the
schema, as well as descriptors for each element in the schema.
Schema elements include tables, types, constraints, views, domains,
and other constructs (such as authorization grants) that describe the
schema.
A schema is created via the CREATE SCHEMA statement, which can
include all the schema elements’ definitions.
Example:- The following statement creates a schema called COMPANY
owned by the user with authorization identifier ‘Jsmith’
Syn:-CREATE SCHEMA COMPANY AUTHORIZATION ‘Jsmith’;
3. 3
In general, not all users are authorized to create schemas and
schema elements. The privilege to create schemas, tables, and other
constructs must be explicitly granted to the relevant user accounts by the
system administrator or DBA.
catalog—a named collection of schemas.
A catalog always contains a special schema called
INFORMATION_SCHEMA, which provides information on all the
schemas in the catalog and all the element descriptors in these
schemas.
4. 4
The CREATE TABLE Command in SQL
CREATE TABLE command is used to specify a new relation by giving it a
name and specifying its attributes and initial constraints.
The attributes are specified first, and each attribute is given a name, a
data type to specify its domain of values, and possibly attribute constraints,
such as NOT NULL.
The key, entity integrity, and referential integrity constraints can be
specified within the CREATE TABLE statement after the attributes are
declared, or they can be added later using the ALTER TABLE command.
Figure 6.1 shows sample data definition statements in SQL for the
COMPANY relational database schema shown below
10. SQL Operators-
The symbols which are used to perform logical and
mathematical operations in SQL are called SQL operators.
Three types of operators used in SQL are as follows:
10
13. 13
Specifying Constraints in SQL
Specifying Attribute Constraints and Attribute Defaults
Because SQL allows NULLs as attribute values, a constraint NOT NULL
may be specified if NULL is not permitted for a particular attribute. This
is always implicitly specified for the attributes that are part of the primary
key of each relation, but it can be specified for any other attributes whose
values are required not to be NULL, as shown in Figure 6.1.
It is also possible to define a default value for an attribute by
appending the clause DEFAULT <value> to an attribute definition. The
default value is included in any new tuple if an explicit value is not provided
for that attribute.
15. 15
Another type of constraint can restrict attribute or domain values using
the CHECK clause following an attribute or domain definition.
Example:-suppose that department numbers are restricted to integer
numbers between 1 and 20; then, we can change the attribute
declaration of Dnumber in the DEPARTMENT table (see Figure 6.1) to the
following:
Dnumber INT NOT NULL CHECK (Dnumber > 0 AND Dnumber < 21);
16. 16
Specifying Key and Referential Integrity Constraints
Some examples to illustrate the specification of keys and referential
integrity are shown in Figure 6.1
17. 17
The PRIMARY KEY clause specifies one or more attributes that make
up the primary key of a relation.
For example, the primary key of DEPARTMENT can be specified as
follows (instead of the way it is specified in Figure 6.1):
Dnumber INT PRIMARY KEY,
The UNIQUE clause specifies alternate (unique) keys, also known as
candidate key as illustrated in the DEPARTMENT and PROJECT table
declarations in Figure 6.1.
The UNIQUE clause can also be specified directly for a unique key if it is
a single attribute, as in the following example:
Dname VARCHAR(15) UNIQUE
18. 18
FOREIGN KEY – Ensure the referential integrity of the data in one
table to match values in another table.
The options include SET NULL, CASCADE, and SET DEFAULT. An
option must be qualified with either ON DELETE or ON UPDATE.
19. 19
The action for CASCADE ON DELETE is to delete all the referencing
tuples, whereas the action for CASCADE ON UPDATE is to change the
value of the referencing foreign key attribute(s) to the updated (new)
primary key value for all the referencing tuples
Giving Names to Constraints
Figure 6.2 also illustrates how a constraint may be given a constraint
name, following the keyword CONSTRAINT.
The names of all constraints within a particular schema must be unique.
A constraint name is used to identify a particular constraint in case the
constraint must be dropped later and replaced with another constraint.
23. 23
Query 0. Retrieve the birth date and address of the employee(s) whose
name is 'John B. Smith'.
QUERY
SELECT Bdate, Address
FROM EMPLOYEE
WHERE Fname = 'John' AND Minit = 'B' AND Lname = 'Smith';
OUTPUT:
24. 24
Query 1. Retrieve the name and address of all employees who work for
the 'Research' department.
Query
SELECT Fname, Lname, Address
FROM EMPLOYEE, DEPARTMENT
WHERE Dname = 'Research' AND Dnumber = Dno;
OUTPUT:
25. 25
Query 2. For every project located in ‘Stafford’, list the project
number, the controlling department number, and the department
manager’s last name, address, and birth date.
Query
SELECT Pnumber, Dnum, Lname, Address, Bdate
FROM PROJECT, DEPARTMENT, EMPLOYEE
WHERE Dnum = Dnumber AND Mgr_ssn = Ssn AND Plocation = 'Stafford';
OUTPUT:
26. 26
Ambiguous Attribute Names, Aliasing, Renaming, and Tuple Variables
In SQL, the same name can be used for two (or more) attributes as
long as the attributes are in different tables.
If this is the case, and a multitable query refers to two or more
attributes with the same name, we must qualify the attribute name
with the relation name to prevent ambiguity.
This is done by prefixing the relation name to the attribute name and
separating the two by a period
27. 27
Query 8. For each employee, retrieve the employee’s first and last
name and the first and last name of his or her immediate supervisor.
Query
SELECT E.Fname, E.Lname, S.Fname, S.Lname
FROM EMPLOYEE E, EMPLOYEE S
WHERE E.Super_ssn = S.Ssn;
OUTPUT:
31. 31
Query Q1C retrieves all the attribute values of any EMPLOYEE who
works in DEPARTMENT number 5
Query
SELECT *
FROM EMPLOYEE
WHERE Dno = 5;
32. 32
Query Q1D retrieves all the attributes of an EMPLOYEE and the
attributes of the DEPARTMENT in which he or she works for every
employee of the ‘Research’ department,
Query
SELECT *
FROM EMPLOYEE, DEPARTMENT
WHERE Dname = ‘Research’ AND Dno = Dnumber;
34. 34
SQL has directly incorporated some of the set operations from
mathematical set theory, which are also part of relational algebra.
There are set union (UNION), set difference (EXCEPT), and set
intersection (INTERSECT) operations.
The relations resulting from these set operations are sets of tuples; that
is, duplicate tuples are eliminated from the result.
These set operations apply only to type compatible relations, so we
must make sure that the two relations on which we apply the operation
have the
same attributes
attributes appear in the same order in both relations.
The next example illustrates the use of UNION.
Tables as Sets in SQL
37. 37
( SELECT DISTINCT Pnumber
FROM PROJECT, DEPARTMENT, EMPLOYEE
WHERE Dnum = Dnumber AND Mgr_ssn = Ssn AND Lname = 'Smith' )
UNION
( SELECT DISTINCT Pnumber
FROM PROJECT, WORKS_ON, EMPLOYEE
WHERE Pnumber = Pno AND Essn = Ssn AND Lname = 'Smith' );
39. 39
Find the fnames of employees who are working in ProductX or
ProductY
select e1.fname from employee e1,works_on w1,project p1
where e1.ssn=w1.essn and w1.pno=p1.pnumber and p1.pname='ProductX'
union
select e2.fname from employee e2,works_on w2,project p2
where e2.ssn=w2.essn and w2.pno=p2.pnumber and p2.pname='ProductY';
40. 40
Find the fnames of employees who are working in ProductX or
ProductY(UNION ALL)
select e1.fname from employee e1,works_on w1,project p1
where e1.ssn=w1.essn and w1.pno=p1.pnumber and p1.pname='ProductX'
Union ALL
select e2.fname from employee e2,works_on w2,project p2
where e2.ssn=w2.essn and w2.pno=p2.pnumber and p2.pname='ProductY';
41. 41
Find the fnames of employees who are working in both ProductX
and ProductY
select e1.fname from employee e1,works_on w1,project p1
where e1.ssn=w1.essn and w1.pno=p1.pnumber and p1.pname='ProductX'
Intersect
select e2.fname from employee e2,works_on w2,project p2
where e2.ssn=w2.essn and w2.pno=p2.pnumber and
p2.pname='ProductY';
42. 42
Find the fnames of employees who are working in ProductY but not
in ProductX
select e2.fname from employee e2,works_on w2,project p2
where e2.ssn=w2.essn and w2.pno=p2.pnumber and p2.pname='ProductY'
minus
select e1.fname from employee e1,works_on w1,project p1
where e1.ssn=w1.essn and w1.pno=p1.pnumber and p1.pname='ProductX';
43. 43
Substring Pattern Matching and Arithmetic Operators
The first feature allows comparison conditions on only parts of a character
string, using the LIKE comparison operator.
This can be used for string pattern matching
Partial strings are specified using two reserved characters
% replaces an arbitrary number of zero or more characters,
(_) replaces a single character. For example, consider the following query.
44. 44
Query 12. Retrieve all employees whose address is in Houston.
QUERY
SELECT Fname, Lname
FROM EMPLOYEE
WHERE Address LIKE ‘%Houston%’;
OUTPUT:
45. 45
Query 12A. Find all employees who were born during the 1950s
QUERY
SELECT Fname, Lname
FROM EMPLOYEE
WHERE Bdate LIKE '_______5_';
OUTPUT:
46. 46
SELECT E.Fname, E.Lname, 1.1 * E.Salary AS Increased_sal
FROM EMPLOYEE E, WORKS_ON W, PROJECT P
WHERE E.Ssn = W.Essn AND W.Pno = P.Pnumber AND P.Pname ='ProductX';
OUTPUT:
48. 48
Ordering of Query Results
Query 15. Retrieve a list of employees and the projects they are working
on, ordered by department and, within each department, ordered
alphabetically by last name, then first name.
49. 49
INSERT, DELETE, and UPDATE Statements in SQL
In SQL, three commands can be used to modify the database: INSERT,
DELETE, and UPDATE.
The INSERT Command
INSERT is used to add a single tuple (row) to a relation (table).
We must specify the relation name and a list of values for the tuple
The values should be listed in the same order in which the
corresponding attributes were specified in the CREATE TABLE
command.
Example:-to add a new tuple to the EMPLOYEE relation
50. 50
DBMS that fully implements SQL should support and enforce all the
integrity constraints that can be specified in the DDL.
For example, if we issue the command in U2 on the database shown in
Figure 5.6, the DBMS should reject the operation because no
DEPARTMENT tuple exists in the database with Dnumber = 2. Similarly,
U2A would be rejected because no Ssn value is provided and it is the
primary key, which cannot be NULL.
51. 51
If you want to create a table D5EMPS with a similar structure to the
EMPLOYEE table and load it with the rows of employees who work in
department 5, we can write the following SQL.
CREATE TABLE D5EMPS1 as select * from EMPLOYEE where e.dno=5;
52. 52
The DELETE command removes tuples from a relation. It includes a
WHERE clause, similar to that used in an SQL query, to select the tuples to
be deleted.
Tuples are explicitly deleted from only one table at a time.
A missing WHERE clause specifies that all tuples in the relation are to be
deleted.
We must use the DROP TABLE command to remove the table definition
The DELETE Command
53. 53
The UPDATE Command
The UPDATE command is used to modify attribute values of one or
more selected tuples.
As in the DELETE command, a WHERE clause in the UPDATE command
selects the tuples to be modified from a single relation.
An additional SET clause in the UPDATE command specifies the
attributes to be modified and their new values.
Actual table
54. 54
Several tuples can be modified with a single UPDATE command.
Example:-
example is to give all employees in the ‘Research’ department a 10%
raise in salary, as shown in U6
55. 55
Joined Tables in SQL and Outer Joins
The concept of a joined table (or joined relation) was incorporated into
SQL to permit users to specify a table resulting from a join operation in the
FROM clause of a query.
56. 56
If the user requires that all employees be included, a different type of join called
OUTER JOIN must be used explicitly.
57. 57
LEFT OUTER JOIN (every tuple in the left table must appear in the
result; if it does not have a matching tuple, it is padded with NULL values
for the attributes of the right table)
RIGHT OUTER JOIN (every tuple in the right table must appear in the
result; if it does not have a matching tuple, it is padded with NULL values
for the attributes of the left table)
The keyword CROSS JOIN is used to specify the CARTESIAN PRODUCT
operation.
It is also possible to nest join specifications; that is, one of the tables in a
join may itself be a joined table. This allows the specification of the join of
three or more tables as a single joined table, which is called a multiway
join
Joins
Hyperlink to local document
59. 59
Aggregate Functions in SQL
Aggregate functions are used to summarize information from
multiple tuples into a single-tuple summary.
A number of built-in aggregate functions exist: COUNT, SUM, MAX,
MIN, and AVG.
COUNT function returns the number of tuples or values as specified in a
query.
These functions can be used in the SELECT clause or in a HAVING
clause.
60. 60
Query 19. Find the sum of the salaries of all employees, the maximum
salary, the minimum salary, and the average salary.
QUERY
SELECT SUM (Salary), MAX (Salary), MIN (Salary), AVG (Salary)
FROM EMPLOYEE;
INPUT
61. 61
Q19A:
SELECT SUM (Salary) Total_Sal, MAX (Salary) Highest_Sal,
MIN (Salary) Lowest_Sal, AVG (Salary) Average_Sal
FROM EMPLOYEE;
62. 62
Query 20. Find the sum of the salaries of all employees of the
‘Research’ department, as well as the maximum salary, the minimum
salary, and the average salary in this department.
63. 63
Queries 21 and 22. Retrieve the total number of employees in the
company
(Q21) and the number of employees in the ‘Research’ department
(Q22).
65. 65
Grouping: The GROUP BY and HAVING Clauses
In many cases we want to apply the aggregate functions to
subgroups of tuples in a relation, where the subgroups are based on
some attribute values.
example, we may want to find the average salary of employees in
each department or the number of employees who work on each
project.
SQL has a GROUP BY clause for this purpose.
The GROUP BY clause specifies the grouping attributes, which
should also appear in the SELECT clause, so that the value resulting
from applying each aggregate function to a group of tuples appears
along with the value of the grouping attribute(s).
66. 66
Query 24. For each department, retrieve the department number, the
number of employees in the department, and their average salary
67. 67
Query 25. For each project, retrieve the project number, the project
name, and the number of employees who work on that project.
68. 68
Query 26.
For each project on which more than two employees work, retrieve
the project number, the project name, and the number of employees
who work on the project.
69. 69
Query 27. For each project, retrieve the project number, the project
name, and the number of employees from department 5 who work on
the project
70. 70
Suppose that we want to count the total number of employees whose
salaries exceed $40,000 in each department, but only for departments
where more than five employees work.
Hint:-Here, the condition (SALARY > 40000) applies only to the COUNT
function in the SELECT clause. Suppose that we write the following
incorrect query:
71. 71
Specifying Constraints as Assertions and Actions as Triggers
Each assertion is given a constraint name and is specified via a
condition similar to the WHERE clause of an SQL query.
Example:- To specify the constraint that the salary of an employee
must not be greater than the salary of the manager of the department
that the employee works for in SQL.
We can write the following assertion:
selects all employees whose
salaries are greater than the
salary of the manager of their
department. If the result
of the query is not empty, the
assertion is violated.
72. 72
A manager may want to be informed if an employee’s travel expenses
exceed a certain limit by receiving a message whenever this occurs. The
action that the DBMS must take in this case is to send an appropriate
message to that user. The condition is thus used to monitor the database
The CREATE TRIGGER statement is used to implement such actions in
SQL.
73. Trigger: A trigger is a stored procedure in database which
automatically invokes whenever a special event in the database
occurs.
For example, a trigger can be invoked when a row is inserted into a
specified table or when certain table columns are being updated.
Syntax:
create trigger [trigger_name]
[before | after]
{insert | update | delete}
on [table_name]
[for each row]
[trigger_body]
Introduction to Triggers in SQL
73
74. create trigger [trigger_name]: Creates or replaces an existing
trigger with the trigger_name.
[before | after]: This specifies when the trigger will be fired.
{insert | update | delete}: This specifies the DML operation.
on [table_name]: This specifies the name of the table associated
with the trigger.
[for each row]: This specifies a row-level trigger, i.e., the trigger will
be executed for each row being affected.
[trigger_body]: This provides the operation to be performed as
trigger is fired Each trigger is attached to a single, specified table in
the database
74
75. We have two types of triggers:
1.Row-level triggers—these are executed for each row
2.Statement-level triggers—at one time, triggers are
executed.
75
79. 79
Create trigger:
The following trigger will display the salary difference between the old
values and new values:
SQL> CREATE OR REPLACE TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE
ON customers
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
sal_diff number;
BEGIN
sal_diff := :NEW.salary - :OLD.salary;
dbms_output.put_line('Old salary: ' || :OLD.salary);
dbms_output.put_line('New salary: ' || :NEW.salary);
dbms_output.put_line('Salary difference: ' || sal_diff);
END;
/
Trigger created.
80. 80
INSERT INTO customers VALUES (7,'Karthik',22,‘VRSEC',87000);
When a record is created in CUSTOMERS table, above create trigger
display_salary_changes will be fired and it will display the following result:
Output:-
SQL> INSERT INTO customers VALUES (7,'Karthik',22,‘VRSEC',87000);
Old salary:
New salary: 87000
Salary difference:
1 row created.
81. 81
Views (Virtual Tables) in SQL
A view in SQL terminology is a single table that is derived from
other tables.
These other tables can be base tables or previously defined views.
A view does not necessarily exist in physical form; it is considered
to be a virtual table, in contrast to base tables, whose tuples are always
physically stored in the database.
Specification of Views in SQL.
In SQL, the command to specify a view is CREATE VIEW. The view is
given a (virtual) table name (or view name), a list of attribute names, and a
query to specify the contents of the view.
82. 82
V1:
CREATE VIEW WORKS_ON1
AS SELECT Fname, Lname, Pname, Hours
FROM EMPLOYEE, PROJECT, WORKS_ON
WHERE Ssn = Essn AND Pno = Pnumber;
84. 84
V2 :
CREATE VIEW DEPT_INFO(Dept_name, No_of_emps, Total_sal)
AS SELECT Dname, COUNT (*), SUM (Salary)
FROM DEPARTMENT, EMPLOYEE
WHERE Dnumber = Dno
GROUP BY Dname;
OUTPUT:
85. 85
We can now specify SQL queries on a view—or virtual table—in the
same way we specify queries involving base tables.
Query: To retrieve the last name and first name of all employees who
work on the ‘ProductX’ project,
we can utilize the WORKS_ON1 view and specify the query as in QV1:
QV1:
SELECT Fname, Lname
FROM WORKS_ON1
WHERE Pname = ‘ProductX’;
86. 86
If we do not need a view anymore,
we can use the DROP VIEW command to dispose of it.
For example, to get rid of the view V1, we can use the SQL statement in
V1A:
DROP VIEW WORKS_ON1;
Different strategies as to when a materialized view is updated are
possible.
The immediate update strategy updates a view as soon as the base
tables are changed;
lazy update strategy updates the view when needed by a view query;
periodic update strategy updates the view periodically (in the latter
strategy, a view query may get a result that is not up-to-date).
87. 87
However, issuing an INSERT, DELETE, or UPDATE command on a view
table is in many cases not possible.
Views defined on multiple tables using joins are generally not
updatable.
Views defined using grouping and aggregate functions are not
updatable.
Views as Authorization Mechanisms
CREATE VIEW DEPT5EMP AS
SELECT *
FROM EMPLOYEE
WHERE Dno = 5;
CREATE VIEW BASIC_EMP_DATA AS
SELECT Fname, Lname, Address
FROM EMPLOYEE;
88. 88
Schema Change Statements in SQL
The DROP Command
The DROP command can be used to drop named schema elements,
such as tables, domains, types, or constraints.
One can also drop a whole schema if it is no longer needed by using
the DROP SCHEMA command.
For example, to remove the COMPANY database schema and all its
tables, domains, and other elements, the CASCADE option is used
as follows:
DROP SCHEMA COMPANY CASCADE;
If the RESTRICT option is chosen in place of CASCADE, the schema is
dropped only if it has no elements in it; otherwise, the DROP command
will not be executed. To use the RESTRICT option, the user must first
individually drop each element in the schema, then drop the schema itself.
89. 89
The ALTER Command
The definition of a base table or of other named schema elements can
be changed by using the ALTER command.
For base tables, the possible alter table actions include adding or
dropping a column (attribute), changing a column definition, and
adding or dropping table constraints.
For example, to add an attribute for keeping track of jobs of employees
to the EMPLOYEE base relation in the COMPANY schema (see Figure 6.1),
we can use the command
ALTER TABLE COMPANY.EMPLOYEE ADD COLUMN Job VARCHAR(12);
90. 90
To drop a column, we must choose either CASCADE or RESTRICT for
drop behavior.
If CASCADE is chosen, all constraints and views that reference the
column are dropped automatically from the schema, along with the column.
If RESTRICT is chosen, the command is successful only if no views or
constraints (or other schema elements) reference the column.
example, the following command removes the attribute Address from the
EMPLOYEE base table:
ALTER TABLE COMPANY.EMPLOYEE DROP COLUMN Address CASCADE;
91. 91
It is also possible to alter a column definition by dropping an existing
default clause or by defining a new default clause. The following
examples illustrate this clause:
ALTER TABLE COMPANY.DEPARTMENT ALTER COLUMN Mgr_ssn DROP
DEFAULT;
ALTER TABLE COMPANY.DEPARTMENT ALTER COLUMN Mgr_ssn
SET DEFAULT ‘333445555’;
One can also change the constraints specified on a table by adding or
dropping a named constraint.
ALTER TABLE COMPANY.EMPLOYEE DROP CONSTRAINT EMPSUPERFK
CASCADE;
92. Functional Dependencies
The single most important concept in relational schema design is
a functional dependency.
A Functional Dependency describes a relationship between
attributes within a single relation
An attribute is functionally dependent on another if we can use
the value of one attribute to determine the value of another.
Formally, functional dependency is defined as;
93. Functional dependency – In a given relation R, X and Y are attributes.
Attribute Y is functionally dependent on attribute X if each value of X
determines exactly one value of Y. This is represented as X → Y.
For example, consider the following relation
Reports(Student#, Course#, CourseName, Iname, Room#, Marks, Grade)
In this relation, {Student#, Course#} together can determine exactly one
value of Marks. This can be symbolically represented as
{Student#, Course#} → Marks
This type of dependency is called as functional dependency. In the above
example Marks is functionally dependent on {Student#, Course#}.
Other functional dependencies in the above example are:
94. Course# → CourseName
Course# → Iname ( Assuming one course is taught by one and
only one instructor)
Iname → Room# (Assuming each instructor has his/her own
room)
Marks → Grade
Course# → Room#
103. Full Functional Dependency - In a given relation R, X and Y are
attributes. Attribute Y is fully functionally dependent on attribute X
only if it is not functionally dependent on sub-set of X where X is
composite in nature.
In the above example, Marks is fully functionally dependent on
{Student#, Course#} and not on sub-set of {Student#, Course#}.
This means Marks cannot be determined either by Student# or by
Course#. It can be determined using Student# and Course#
together. Hence, Marks is fully functionally dependent on
{Student#, Course#}.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115. For example,
suppose there is a relation R (A, B, C, D) with
functional dependency set (A->BC).
The relational R is decomposed into
R1(ABC)
R2(AD)
Solution:
It id dependency preserving
because FD A->BC is a part of relation R1(ABC).
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131. VRSEC-CSE-DBMS-III-B-VR_20 131
FOURTH NORMAL FORM-4NF
A multivalued dependency X → Y specified on relation schema R, where
X and Y are both subsets of R, specifies the following constraint on any
relation state r of R:
If two tuples t1 and t2 exist in r such that t1[X] = t2[X], then two tuples t3
and t4 should also exist in r with the following properties, where we use Z
to denote (R − (X ∪ Y)):
Definition:
A Relation R is in 4NF if and only if the following conditions are satisfied
(i) R is in already BCNF or 3NF
(ii) R contains no MVDs