SlideShare a Scribd company logo
Beyond SQL | Comparing SQL to TypeQL
Tomás Sabat
Sure, you can express a question by writing a navigational plan,
but the navigational plan is not the essence of what you're trying
to accomplish. [...]
Wouldn't it be nice if you could express the question at a higher
level and let the system figure out how to do the navigation?
– Edgar “Ted” Codd
A language that you can read and understand intuitively enables
you to ask questions at a higher level, while letting the system
figure out how to do the lower level operations.
that you can read and understand intuitively
enables
you to ask questions at a higher level
while letting the system
figure out how to do the lower level operations.
Let’s discuss…
Data Modelling
Writing and Reading (Relationally)
Hypergraph and Automated Reasoning
Entity-Relationship Modelling
Normalisation
SSN Pnumber Hours Ename Pname Plocation
FD1
FD2
FD3
SSN Pnumber Hours
FD1
SSN Ename
FD2
Pnumber Pname Plocation
FD3
2NF Normalisation
Ename Ssn Bdate Address Dnumber Dname Dmgr_ssn
3NF Normalisation
Ename Ssn Bdate Address Dnumber Dnumber Dname Dmgr_ssn
Database Architecture
Logical Model
Physical Level
Conceptual Model
Database Architecture
ER Diagram
Logical Model
Physical Level
Conceptual Model
Database Architecture
ER Diagram
Normalisation
3NF Logical Model
Physical Level
Conceptual Model
Database Architecture
ER Diagram
Normalisation
3NF
DBMS
Physical independence of data
Logical Model
Physical Level
Conceptual Model
Entity-Relationship Modelling
Entity-Relationship Modelling
From ER Diagram to TypeDB
employee
name
bdate
…
supervision
supervisee
supervisor
ssn
Database Architecture
ER Diagram
Normalisation
3NF
DBMS
Physical independence of data
Logical Model
Physical Level
Conceptual Model
Database Architecture
ER Diagram
Normalisation
3NF TypeDB
Abstraction Over Logical Model
X
X
X Logical Model
Physical Level
Conceptual Model
Database Architecture
Conceptual and
Logical Model
ER Diagram
Normalisation
3NF
X
X
X
Abstraction Over Logical Model
Physical Level
TypeDB
The Northwind Dataset
Defining Schemas
Defining Schemas
products
product_id: PK
product_name
category_id: FK
quantity_per_unit
Defining Schemas
product
products
product_id: PK
product_name
category_id: FK
quantity_per_unit
Defining Schemas
product
product-id
product-key
quantity-
per-unit
products
product_id: PK
product_name
category_id: FK
quantity_per_unit
Defining Schemas
product
product-id
product-key
quantity-
per-unit
products
product_id: PK
product_name
category_id: FK
quantity_per_unit
category-id
Defining Schemas
product
product-id
product-key
quantity-
per-unit
products
product_id: PK
product_name
category_id: FK
quantity_per_unit
category-id
X
Defining Schemas
product-id
product-key
quantity-
per-unit
category
assignment
product-assignment
assigned-category
product
products
product_id: PK
product_name
category_id: FK
quantity_per_unit
CREATE TABLE products (
);
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
);
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
);
define
product sub entity;
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
);
define
product sub entity,
owns product-id @key;
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
);
define
product sub entity,
owns product-id @key,
owns product-name,
owns quantity-per-unit;
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
);
define
product sub entity,
owns product-id @key,
owns product-name,
owns quantity-per-unit;
product-id sub attribute, value double;
product-name sub attribute, value string;
quantity-per-unit sub attribute, value
double;
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
FOREIGN KEY (category_id) REFERENCES
categories
);
define
product sub entity,
owns product-id @key,
owns product-name,
owns quantity-per-unit;
product-id sub attribute, value double;
product-name sub attribute, value string;
quantity-per-unit sub attribute, value
double;
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
FOREIGN KEY (category_id) REFERENCES
categories
);
define
product sub entity,
owns product-id @key,
owns product-name,
owns quantity-per-unit,
plays assignment:assigned;
product-id sub attribute, value double;
product-name sub attribute, value string;
quantity-per-unit sub attribute, value
double;
Defining Schemas – Create an Entity
CREATE TABLE products (
product_id smallint NOT NULL PRIMARY KEY,
product_name character varying(40) NOT
NULL,
category_id smallint,
quantity_per_unit character varying(20),
FOREIGN KEY (category_id) REFERENCES
categories
);
define
product sub entity,
owns product-id @key,
owns product-name,
owns quantity-per-unit,
plays assignment:assigned;
product-id sub attribute, value double;
product-name sub attribute, value string;
quantity-per-unit sub attribute, value
double;
assignment sub relation,
relates category,
relates assigned;
Defining Schemas – Create an Entity
Let’s discuss…
Data Modelling
Writing and Reading (Relationally)
Hypergraph and Automated Reasoning
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
SELECT category.categoryID
FROM category
WHERE category.CategoryName = 'Confections';
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
SELECT category.categoryID
FROM category
WHERE category.CategoryName = 'Confections';
INSERT INTO products
VALUES (12, 'Chocolate', 42, 421)
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
SELECT category.categoryID
FROM category
WHERE category.CategoryName = 'Confections';
INSERT INTO products
VALUES (12, 'Chocolate', 42, 421)
match
$c isa category,
has name "Confections";
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
SELECT category.categoryID
FROM category
WHERE category.CategoryName = 'Confections';
INSERT INTO products
VALUES (12, 'Chocolate', 42, 421)
match
$c isa category,
has name "Confections";
insert
$p isa product;
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
SELECT category.categoryID
FROM category
WHERE category.CategoryName = 'Confections';
INSERT INTO products
VALUES (12, 'Chocolate', 42, 421)
match
$c isa category,
has name "Confections";
insert
$p isa product,
has product-id 12,
has product-name "Chocolate",
has quantity-per-unit 421;
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
SELECT category.categoryID
FROM category
WHERE category.CategoryName = 'Confections';
INSERT INTO products
VALUES (12, 'Chocolate', 42, 421)
match
$c isa category,
has name "Confections";
insert
$p isa product,
has product-id 12,
has product-name "Chocolate",
has quantity-per-unit 421;
$r ($c, $p) isa assignment;
Inserting Data
Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name
“Confections”.
Reading Data
SELECT column1, column2, …
FROM table_name;
WHERE condition;
Reading Data
SELECT column1, column2, …
FROM table_name;
WHERE condition;
match
$a isa thing,
has attribute $v;
get $a, $v;
Projection
Return all product IDs and the unit prices.
Projection
Return all product IDs and the unit prices.
ProductID ProductName CategoryID UnitPrice QuantityPerUnit
Projection
Return all product IDs and the unit prices.
ProductID ProductName CategoryID UnitPrice QuantityPerUnit
product
productID
$pid
unit-price
$up
Restrict
Return product IDs and product names, for products with a unit price higher than 12.5.
Restrict
Return product IDs and product names, for products with a unit price higher than 12.5.
ProductID ProductName CategoryID UnitPrice QuantityPerUnit
>12.5
>12.5
>12.5
Restrict
Return product IDs and product names, for products with a unit price higher than 12.5.
product
unit-price
>12.5
productID
$pid
product-name
$pn
ProductID ProductName CategoryID UnitPrice QuantityPerUnit
>12.5
>12.5
>12.5
Union
Get all the different cities in which suppliers and customers are located.
Union
Get all the different cities in which suppliers and customers are located.
Cities
Cities
Suppliers
Customers
Union
Get all the different cities in which suppliers and customers are located.
Cities
Cities
Suppliers
Customers
city
city-name
$cn
located
customer supplier
located OR
Intersection
Get a list of cities where both customers and suppliers are located.
Intersection
Get a list of cities where both customers and suppliers are located.
Cities
Cities
Suppliers
Customers
Intersection
Get a list of cities where both customers and suppliers are located.
city
city-name
$cn
Cities
Cities
Suppliers
Customers
located
customer supplier
located AND
Intersection
Get a list of cities where both customers and suppliers are located.
city
city-name
$cn
Cities
Cities
Suppliers
Customers
located
customer supplier
located AND
Join
Return the corresponding category names for each product name.
Join
Return the corresponding category names for each product name.
CategoryName … ProductName ...
CategoryName ProductName
Categories Products
Join
Return the corresponding category names for each product name.
category
category-name
$cn
assignment
product
product-name
$pn
CategoryName … ProductName ...
CategoryName ProductName
Categories Products
Let’s discuss…
Data Modelling
Writing and Reading (Relationally)
Hypergraph and Automated Reasoning
Hyper-relationships
product
company
order
employee
Hyper-relationships
sale
containing
stocking
product
company
order
employee
Hyper-relationships
contained-product
sale
seller
placed-order
customer
containing
containing-order
supplier
stocking
stock
product
company
order
employee
Hyper-relationships
unit-price
quantity
contained-product
sale
supplier
seller
placed-order
containing
containing-order
stocking
customer
stock
product
company
order
employee
define
employee sub entity;
company sub entity;
order sub entity;
product sub entity;
Hyper-relationships
define
employee sub entity;
company sub entity;
order sub entity;
product sub entity;
sale sub relation,
relates seller,
relates placed-order,
relates customer;
Hyper-relationships
define
employee sub entity;
company sub entity;
order sub entity;
product sub entity;
sale sub relation,
relates seller,
relates placed-order,
relates customer;
containing sub relation,
owns quantity,
owns unit-price,
relates product,
relates containing-order;
Hyper-relationships
define
employee sub entity;
company sub entity;
order sub entity;
product sub entity;
sale sub relation,
relates seller,
relates placed-order,
relates customer;
containing sub relation,
owns quantity,
owns unit-price,
relates product,
relates containing-order;
stocking sub relation,
relates stock,
relates supplier;
Hyper-relationships
define
employee sub entity,
plays sale:seller;
company sub entity,
plays stocking:supplier,
plays sale:customer;
order sub entity,
plays containing:placed-order,
plays sale:containing-order;
product sub entity,
plays containing:product,
plays stocking:stock;
sale sub relation,
relates seller,
relates placed-order,
relates customer;
containing sub relation,
owns quantity,
owns unit-price,
relates product,
relates containing-order;
stocking sub relation,
relates stock,
relates supplier;
Hyper-relationships
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
Traversal Query
employee-id
employee
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
Traversal Query
sale
supplier customer
seller
employee-id
employee company
city
’London’
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
Traversal Query
employee sale company
customer-
description
supplier customer
seller
demographic
’x’
employee-id city
’London’
…
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
match
$s isa employee,
has employee-id $eid;
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
match
$s isa employee,
has employee-id $eid;
$c isa company,
has city "London";
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
match
$s isa employee,
has employee-id $eid;
$c isa company,
has city "London";
$r1(seller: $s, customer: $c) isa sale;
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
match
$s isa employee,
has employee-id $eid;
$c isa company,
has city "London";
$r1(seller: $s, customer: $c) isa sale;
$cd isa customer-demographic,
has customer-description 'x';
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
match
$s isa employee,
has employee-id $eid;
$c isa company,
has city "London";
$r1(seller: $s, customer: $c) isa sale;
$cd isa customer-demographic,
has customer-description 'x';
$r2 ($c, $cd);
Traversal Query
Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
SELECT Employees.EmployeeID
FROM Employees
INNER JOIN Orders ON
Employees.EmployeeID = Orders.EmployeeID
INNER JOIN Customers ON
Orders.CustomerID = Customers.CustomerID
AND Customers.City = 'London'
INNER JOIN CustomerCustomerDemo ON
Customers.CustomerID =
CustomerCustomerDemo.CustomerID
INNER JOIN CustomerDemographic ON
CustomerCustomerDemo.CustomerTypeId =
CustomerDemographic.CustomerTypeId AND
CustomerCustomerDemo.CustomerDesc = 'x'
match
$s isa employee,
has employee-id $eid;
$c isa company,
has city "London";
$r1(seller: $s, customer: $c) isa sale;
$cd isa customer-demographic,
has customer-description 'x';
$r2 ($c, $cd);
get $eid;
Traversal Query
Type-based Reasoning
Type-based Reasoning
organisation
Type-based Reasoning
non-profit
organisation
sub
for-profit
sub
Type-based Reasoning
non-profit
organisation
sub
for-profit
bank pharmaceutical
sub
sub
sub
Type-based Reasoning
define
organisation sub entity;
organisation
Type-based Reasoning
define
organisation sub entity;
for-profit sub organisation;
non-profit sub organisation;
non-profit
organisation
sub
for-profit
sub
Type-based Reasoning
define
organisation sub entity;
for-profit sub organisation;
non-profit sub organisation;
bank sub for-profit;
pharmaceutical sub for-profit;
non-profit
organisation
sub
for-profit
bank pharmaceutical
sub
sub
sub
Rule-based Reasoning
x y z
Rule-based Reasoning
x y z
location
location
Rule-based Reasoning
location
location
location
x y z
Rule-based Reasoning
rule transitive-location:
when {
} then {
};
location
x y z
location
location
Rule-based Reasoning
rule transitive-location:
when {
(located: $x, locating: $y);
(located: $y, locating: $z);
} then {
};
x y z
location
location
location
Rule-based Reasoning
rule transitive-location:
when {
(located: $x, locating: $y);
(located: $y, locating: $z);
} then {
(located: $x, locating: $z);
};
x y z
location
location
location
Return all the employee IDs who are in a region with region-description ‘x’.
SELECT Employee.EmployeeID
FROM Employee
Rule-based Reasoning
Return all the employee IDs who are in a region with region-description ‘x’.
SELECT Employee.EmployeeID
FROM Employee
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
Rule-based Reasoning
Return all the employee IDs who are in a region with region-description ‘x’.
SELECT Employee.EmployeeID
FROM Employee
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$r isa region, has region-description "x";
Rule-based Reasoning
Return all the employee IDs who are in a region with region-description ‘x’.
SELECT Employee.EmployeeID
FROM Employee
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$e isa employee, has employee-id $eid;
$r isa region, has region-description "x";
Rule-based Reasoning
Return all the employee IDs who are in a region with region-description ‘x’.
SELECT Employee.EmployeeID
FROM Employee
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$e isa employee, has employee-id $eid;
$r isa region, has region-description "x";
$r1 (located: $e, locating: $r);
Rule-based Reasoning
Return all the employee IDs who are in a region with region-description ‘x’.
SELECT Employee.EmployeeID
FROM Employee
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$e isa employee, has employee-id $eid;
$r isa region, has region-description "x";
$r1 (located: $e, locating: $r);
get $eid;
Rule-based Reasoning
Rule-based Reasoning
Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region-
description "x".
Rule-based Reasoning
Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region-
description "x".
charities
companies
Rule-based Reasoning
Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region-
description "x".
charities
companies orders
orders
Rule-based Reasoning
Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region-
description "x".
charities
companies orders employee
orders employee
Rule-based Reasoning
Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region-
description "x".
charities
companies territory
territory
orders employee
orders employee
Rule-based Reasoning
Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region-
description "x".
charities
companies orders
orders
region
‘x’
territory
territory
employee
employee
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$c isa organisation, has org-id $ci;
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$c isa organisation, has org-id $ci;
$e isa employee;
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$c isa organisation, has org-id $ci;
$e isa employee;
$r2 ($c, $e) isa sale;
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$c isa organisation, has org-id $ci;
$e isa employee;
$r isa region, has region-description "x";
$r2 ($c, $e) isa sale;
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$c isa organisation, has org-id $ci;
$e isa employee;
$r isa region, has region-description "x";
$r1 (located: $e, locating: $r);
$r2 ($c, $e) isa sale;
Rule-based Reasoning
Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x".
SELECT Companies.OrgID
FROM Companies
INNER JOIN Orders ON
Companies.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
UNION
SELECT Charities.OrgID
FROM Charities
INNER JOIN Orders ON
Charities.OrgId = Orders.OrgId
INNER JOIN Employees ON
Orders.OrgId = Employees.OrgId
INNER JOIN EmployeeTerritories AS Et ON
Employee.EmployeeID = Et.EmployeeID
INNER JOIN Territories AS Te ON
Te.TerritoryID = Et.TerritoryID
INNER JOIN Region AS Re ON
Re.RegionDescription = 'x'
match
$c isa organisation, has org-id $ci;
$e isa employee;
$r isa region, has region-description "x";
$r1 (located: $e, locating: $r);
$r2 ($c, $e) isa sale;
get $ci;
Rule-based Reasoning
Conceptual and
Logical Model
ER Diagram
Normalisation
3NF TypeDB
X
X
X
Abstraction Over Logical Model
Physical Level
A language that you can read and understand intuitively enables
you to ask questions at a higher level, while letting the system
figure out how to do the lower level operations.
Thank you for attending this webinar!

More Related Content

Similar to Beyond SQL - Comparing SQL to TypeQL

Introduction to SQL Antipatterns
Introduction to SQL AntipatternsIntroduction to SQL Antipatterns
Introduction to SQL Antipatterns
Krishnakumar S
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
lilredlokita
 
Sql vs no sql diponkar paul-april 2020-Toronto PASS
Sql vs no sql   diponkar paul-april 2020-Toronto PASSSql vs no sql   diponkar paul-april 2020-Toronto PASS
Sql vs no sql diponkar paul-april 2020-Toronto PASS
Diponkar Paul
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
Elixir, GraphQL and Vue.js
Elixir, GraphQL and Vue.jsElixir, GraphQL and Vue.js
Elixir, GraphQL and Vue.js
Jeroen Visser
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
Er. Nawaraj Bhandari
 
Android sql examples
Android sql examplesAndroid sql examples
Android sql examples
Aravindharamanan S
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Amin Choroomi
 
Personalized Search on the Largest Flash Sale Site in America
Personalized Search on the Largest Flash Sale Site in AmericaPersonalized Search on the Largest Flash Sale Site in America
Personalized Search on the Largest Flash Sale Site in America
Adrian Trenaman
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQ
Nguyen Tuan
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
Lori Moore
 
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave ClubJoining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Data Con LA
 
Sql server building a database ppt 12
Sql server building a database ppt 12Sql server building a database ppt 12
Sql server building a database ppt 12
Vibrant Technologies & Computers
 
Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101
IDERA Software
 
Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片
cfc
 
IT301-Datawarehousing (1) and its sub topics.pptx
IT301-Datawarehousing (1) and its sub topics.pptxIT301-Datawarehousing (1) and its sub topics.pptx
IT301-Datawarehousing (1) and its sub topics.pptx
ReneeClintGortifacio
 
Sql vs no sql and azure data factory glasgow data UG
Sql vs no sql and azure data factory  glasgow data UGSql vs no sql and azure data factory  glasgow data UG
Sql vs no sql and azure data factory glasgow data UG
Diponkar Paul
 
Documentation For Tab Setup
Documentation For Tab SetupDocumentation For Tab Setup
Documentation For Tab Setup
vkeeton
 
Unidad 4 actividad 1
Unidad 4 actividad 1Unidad 4 actividad 1
Unidad 4 actividad 1KARY
 

Similar to Beyond SQL - Comparing SQL to TypeQL (20)

Introduction to SQL Antipatterns
Introduction to SQL AntipatternsIntroduction to SQL Antipatterns
Introduction to SQL Antipatterns
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
Sql vs no sql diponkar paul-april 2020-Toronto PASS
Sql vs no sql   diponkar paul-april 2020-Toronto PASSSql vs no sql   diponkar paul-april 2020-Toronto PASS
Sql vs no sql diponkar paul-april 2020-Toronto PASS
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Elixir, GraphQL and Vue.js
Elixir, GraphQL and Vue.jsElixir, GraphQL and Vue.js
Elixir, GraphQL and Vue.js
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
 
Android sql examples
Android sql examplesAndroid sql examples
Android sql examples
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Personalized Search on the Largest Flash Sale Site in America
Personalized Search on the Largest Flash Sale Site in AmericaPersonalized Search on the Largest Flash Sale Site in America
Personalized Search on the Largest Flash Sale Site in America
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQ
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
 
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave ClubJoining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
 
Sql server building a database ppt 12
Sql server building a database ppt 12Sql server building a database ppt 12
Sql server building a database ppt 12
 
DBMS LAB
DBMS LABDBMS LAB
DBMS LAB
 
Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101
 
Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片
 
IT301-Datawarehousing (1) and its sub topics.pptx
IT301-Datawarehousing (1) and its sub topics.pptxIT301-Datawarehousing (1) and its sub topics.pptx
IT301-Datawarehousing (1) and its sub topics.pptx
 
Sql vs no sql and azure data factory glasgow data UG
Sql vs no sql and azure data factory  glasgow data UGSql vs no sql and azure data factory  glasgow data UG
Sql vs no sql and azure data factory glasgow data UG
 
Documentation For Tab Setup
Documentation For Tab SetupDocumentation For Tab Setup
Documentation For Tab Setup
 
Unidad 4 actividad 1
Unidad 4 actividad 1Unidad 4 actividad 1
Unidad 4 actividad 1
 

More from Vaticle

Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug DiscoveryBuilding Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
Vaticle
 
Loading Huge Amounts of Data
Loading Huge Amounts of DataLoading Huge Amounts of Data
Loading Huge Amounts of Data
Vaticle
 
Natural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge GraphNatural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge Graph
Vaticle
 
A Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security KnowledgeA Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security Knowledge
Vaticle
 
Unifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & Knowledge GraphUnifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & Knowledge Graph
Vaticle
 
The Next Big Thing in AI - Causality
The Next Big Thing in AI - CausalityThe Next Big Thing in AI - Causality
The Next Big Thing in AI - Causality
Vaticle
 
Building a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge GraphBuilding a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge Graph
Vaticle
 
Knowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdfKnowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdf
Vaticle
 
Building a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdfBuilding a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdf
Vaticle
 
Enabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdfEnabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdf
Vaticle
 
TypeDB Academy | Inference with Rules
TypeDB Academy | Inference with RulesTypeDB Academy | Inference with Rules
TypeDB Academy | Inference with Rules
Vaticle
 
TypeDB Academy | Modelling Principles
TypeDB Academy | Modelling PrinciplesTypeDB Academy | Modelling Principles
TypeDB Academy | Modelling Principles
Vaticle
 
Comparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDBComparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDB
Vaticle
 
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning EngineReasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
Vaticle
 
Intro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed databaseIntro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed database
Vaticle
 
Graph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphsGraph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphs
Vaticle
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDB
Vaticle
 
Strongly Typed Data for Machine Learning
Strongly Typed Data for Machine LearningStrongly Typed Data for Machine Learning
Strongly Typed Data for Machine Learning
Vaticle
 
Open World Robotics
Open World RoboticsOpen World Robotics
Open World Robotics
Vaticle
 
Combining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital TransformationCombining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital Transformation
Vaticle
 

More from Vaticle (20)

Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug DiscoveryBuilding Biomedical Knowledge Graphs for In-Silico Drug Discovery
Building Biomedical Knowledge Graphs for In-Silico Drug Discovery
 
Loading Huge Amounts of Data
Loading Huge Amounts of DataLoading Huge Amounts of Data
Loading Huge Amounts of Data
 
Natural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge GraphNatural Language Interface to Knowledge Graph
Natural Language Interface to Knowledge Graph
 
A Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security KnowledgeA Data Modelling Framework to Unify Cyber Security Knowledge
A Data Modelling Framework to Unify Cyber Security Knowledge
 
Unifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & Knowledge GraphUnifying Space Mission Knowledge with NLP & Knowledge Graph
Unifying Space Mission Knowledge with NLP & Knowledge Graph
 
The Next Big Thing in AI - Causality
The Next Big Thing in AI - CausalityThe Next Big Thing in AI - Causality
The Next Big Thing in AI - Causality
 
Building a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge GraphBuilding a Cyber Threat Intelligence Knowledge Graph
Building a Cyber Threat Intelligence Knowledge Graph
 
Knowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdfKnowledge Graphs for Supply Chain Operations.pdf
Knowledge Graphs for Supply Chain Operations.pdf
 
Building a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdfBuilding a Distributed Database with Raft.pdf
Building a Distributed Database with Raft.pdf
 
Enabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdfEnabling the Computational Future of Biology.pdf
Enabling the Computational Future of Biology.pdf
 
TypeDB Academy | Inference with Rules
TypeDB Academy | Inference with RulesTypeDB Academy | Inference with Rules
TypeDB Academy | Inference with Rules
 
TypeDB Academy | Modelling Principles
TypeDB Academy | Modelling PrinciplesTypeDB Academy | Modelling Principles
TypeDB Academy | Modelling Principles
 
Comparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDBComparing Semantic Web Technologies to TypeDB
Comparing Semantic Web Technologies to TypeDB
 
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning EngineReasoner, Meet Actors | TypeDB's Native Reasoning Engine
Reasoner, Meet Actors | TypeDB's Native Reasoning Engine
 
Intro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed databaseIntro to TypeDB and TypeQL | A strongly-typed database
Intro to TypeDB and TypeQL | A strongly-typed database
 
Graph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphsGraph Databases vs TypeDB | What you can't do with graphs
Graph Databases vs TypeDB | What you can't do with graphs
 
Pandora Paper Leaks With TypeDB
 Pandora Paper Leaks With TypeDB Pandora Paper Leaks With TypeDB
Pandora Paper Leaks With TypeDB
 
Strongly Typed Data for Machine Learning
Strongly Typed Data for Machine LearningStrongly Typed Data for Machine Learning
Strongly Typed Data for Machine Learning
 
Open World Robotics
Open World RoboticsOpen World Robotics
Open World Robotics
 
Combining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital TransformationCombining Causal and Knowledge Modeling for Digital Transformation
Combining Causal and Knowledge Modeling for Digital Transformation
 

Recently uploaded

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Beyond SQL - Comparing SQL to TypeQL

  • 1. Beyond SQL | Comparing SQL to TypeQL Tomás Sabat
  • 2.
  • 3.
  • 4. Sure, you can express a question by writing a navigational plan, but the navigational plan is not the essence of what you're trying to accomplish. [...] Wouldn't it be nice if you could express the question at a higher level and let the system figure out how to do the navigation? – Edgar “Ted” Codd
  • 5.
  • 6.
  • 7. A language that you can read and understand intuitively enables you to ask questions at a higher level, while letting the system figure out how to do the lower level operations.
  • 8. that you can read and understand intuitively
  • 9. enables you to ask questions at a higher level
  • 10. while letting the system figure out how to do the lower level operations.
  • 11. Let’s discuss… Data Modelling Writing and Reading (Relationally) Hypergraph and Automated Reasoning
  • 13. Normalisation SSN Pnumber Hours Ename Pname Plocation FD1 FD2 FD3 SSN Pnumber Hours FD1 SSN Ename FD2 Pnumber Pname Plocation FD3 2NF Normalisation Ename Ssn Bdate Address Dnumber Dname Dmgr_ssn 3NF Normalisation Ename Ssn Bdate Address Dnumber Dnumber Dname Dmgr_ssn
  • 15. Database Architecture ER Diagram Logical Model Physical Level Conceptual Model
  • 16. Database Architecture ER Diagram Normalisation 3NF Logical Model Physical Level Conceptual Model
  • 17. Database Architecture ER Diagram Normalisation 3NF DBMS Physical independence of data Logical Model Physical Level Conceptual Model
  • 20. From ER Diagram to TypeDB employee name bdate … supervision supervisee supervisor ssn
  • 21. Database Architecture ER Diagram Normalisation 3NF DBMS Physical independence of data Logical Model Physical Level Conceptual Model
  • 22. Database Architecture ER Diagram Normalisation 3NF TypeDB Abstraction Over Logical Model X X X Logical Model Physical Level Conceptual Model
  • 23. Database Architecture Conceptual and Logical Model ER Diagram Normalisation 3NF X X X Abstraction Over Logical Model Physical Level TypeDB
  • 32. CREATE TABLE products ( ); Defining Schemas – Create an Entity
  • 33. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), ); Defining Schemas – Create an Entity
  • 34. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), ); define product sub entity; Defining Schemas – Create an Entity
  • 35. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), ); define product sub entity, owns product-id @key; Defining Schemas – Create an Entity
  • 36. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), ); define product sub entity, owns product-id @key, owns product-name, owns quantity-per-unit; Defining Schemas – Create an Entity
  • 37. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), ); define product sub entity, owns product-id @key, owns product-name, owns quantity-per-unit; product-id sub attribute, value double; product-name sub attribute, value string; quantity-per-unit sub attribute, value double; Defining Schemas – Create an Entity
  • 38. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), FOREIGN KEY (category_id) REFERENCES categories ); define product sub entity, owns product-id @key, owns product-name, owns quantity-per-unit; product-id sub attribute, value double; product-name sub attribute, value string; quantity-per-unit sub attribute, value double; Defining Schemas – Create an Entity
  • 39. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), FOREIGN KEY (category_id) REFERENCES categories ); define product sub entity, owns product-id @key, owns product-name, owns quantity-per-unit, plays assignment:assigned; product-id sub attribute, value double; product-name sub attribute, value string; quantity-per-unit sub attribute, value double; Defining Schemas – Create an Entity
  • 40. CREATE TABLE products ( product_id smallint NOT NULL PRIMARY KEY, product_name character varying(40) NOT NULL, category_id smallint, quantity_per_unit character varying(20), FOREIGN KEY (category_id) REFERENCES categories ); define product sub entity, owns product-id @key, owns product-name, owns quantity-per-unit, plays assignment:assigned; product-id sub attribute, value double; product-name sub attribute, value string; quantity-per-unit sub attribute, value double; assignment sub relation, relates category, relates assigned; Defining Schemas – Create an Entity
  • 41. Let’s discuss… Data Modelling Writing and Reading (Relationally) Hypergraph and Automated Reasoning
  • 42. Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 43. SELECT category.categoryID FROM category WHERE category.CategoryName = 'Confections'; Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 44. SELECT category.categoryID FROM category WHERE category.CategoryName = 'Confections'; INSERT INTO products VALUES (12, 'Chocolate', 42, 421) Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 45. SELECT category.categoryID FROM category WHERE category.CategoryName = 'Confections'; INSERT INTO products VALUES (12, 'Chocolate', 42, 421) match $c isa category, has name "Confections"; Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 46. SELECT category.categoryID FROM category WHERE category.CategoryName = 'Confections'; INSERT INTO products VALUES (12, 'Chocolate', 42, 421) match $c isa category, has name "Confections"; insert $p isa product; Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 47. SELECT category.categoryID FROM category WHERE category.CategoryName = 'Confections'; INSERT INTO products VALUES (12, 'Chocolate', 42, 421) match $c isa category, has name "Confections"; insert $p isa product, has product-id 12, has product-name "Chocolate", has quantity-per-unit 421; Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 48. SELECT category.categoryID FROM category WHERE category.CategoryName = 'Confections'; INSERT INTO products VALUES (12, 'Chocolate', 42, 421) match $c isa category, has name "Confections"; insert $p isa product, has product-id 12, has product-name "Chocolate", has quantity-per-unit 421; $r ($c, $p) isa assignment; Inserting Data Insert a new product with product name “Chocolate”, product id 12, quantity per unit 421 and category name “Confections”.
  • 49. Reading Data SELECT column1, column2, … FROM table_name; WHERE condition;
  • 50. Reading Data SELECT column1, column2, … FROM table_name; WHERE condition; match $a isa thing, has attribute $v; get $a, $v;
  • 51. Projection Return all product IDs and the unit prices.
  • 52. Projection Return all product IDs and the unit prices. ProductID ProductName CategoryID UnitPrice QuantityPerUnit
  • 53. Projection Return all product IDs and the unit prices. ProductID ProductName CategoryID UnitPrice QuantityPerUnit product productID $pid unit-price $up
  • 54. Restrict Return product IDs and product names, for products with a unit price higher than 12.5.
  • 55. Restrict Return product IDs and product names, for products with a unit price higher than 12.5. ProductID ProductName CategoryID UnitPrice QuantityPerUnit >12.5 >12.5 >12.5
  • 56. Restrict Return product IDs and product names, for products with a unit price higher than 12.5. product unit-price >12.5 productID $pid product-name $pn ProductID ProductName CategoryID UnitPrice QuantityPerUnit >12.5 >12.5 >12.5
  • 57. Union Get all the different cities in which suppliers and customers are located.
  • 58. Union Get all the different cities in which suppliers and customers are located. Cities Cities Suppliers Customers
  • 59. Union Get all the different cities in which suppliers and customers are located. Cities Cities Suppliers Customers city city-name $cn located customer supplier located OR
  • 60. Intersection Get a list of cities where both customers and suppliers are located.
  • 61. Intersection Get a list of cities where both customers and suppliers are located. Cities Cities Suppliers Customers
  • 62. Intersection Get a list of cities where both customers and suppliers are located. city city-name $cn Cities Cities Suppliers Customers located customer supplier located AND Intersection Get a list of cities where both customers and suppliers are located. city city-name $cn Cities Cities Suppliers Customers located customer supplier located AND
  • 63. Join Return the corresponding category names for each product name.
  • 64. Join Return the corresponding category names for each product name. CategoryName … ProductName ... CategoryName ProductName Categories Products
  • 65. Join Return the corresponding category names for each product name. category category-name $cn assignment product product-name $pn CategoryName … ProductName ... CategoryName ProductName Categories Products
  • 66. Let’s discuss… Data Modelling Writing and Reading (Relationally) Hypergraph and Automated Reasoning
  • 67.
  • 68.
  • 73. define employee sub entity; company sub entity; order sub entity; product sub entity; Hyper-relationships
  • 74. define employee sub entity; company sub entity; order sub entity; product sub entity; sale sub relation, relates seller, relates placed-order, relates customer; Hyper-relationships
  • 75. define employee sub entity; company sub entity; order sub entity; product sub entity; sale sub relation, relates seller, relates placed-order, relates customer; containing sub relation, owns quantity, owns unit-price, relates product, relates containing-order; Hyper-relationships
  • 76. define employee sub entity; company sub entity; order sub entity; product sub entity; sale sub relation, relates seller, relates placed-order, relates customer; containing sub relation, owns quantity, owns unit-price, relates product, relates containing-order; stocking sub relation, relates stock, relates supplier; Hyper-relationships
  • 77. define employee sub entity, plays sale:seller; company sub entity, plays stocking:supplier, plays sale:customer; order sub entity, plays containing:placed-order, plays sale:containing-order; product sub entity, plays containing:product, plays stocking:stock; sale sub relation, relates seller, relates placed-order, relates customer; containing sub relation, owns quantity, owns unit-price, relates product, relates containing-order; stocking sub relation, relates stock, relates supplier; Hyper-relationships
  • 78. Traversal Query Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
  • 79. Traversal Query employee-id employee Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
  • 80. Traversal Query sale supplier customer seller employee-id employee company city ’London’ Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’.
  • 81. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. Traversal Query employee sale company customer- description supplier customer seller demographic ’x’ employee-id city ’London’ …
  • 82. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees Traversal Query
  • 83. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' Traversal Query
  • 84. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' match $s isa employee, has employee-id $eid; Traversal Query
  • 85. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' match $s isa employee, has employee-id $eid; $c isa company, has city "London"; Traversal Query
  • 86. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' match $s isa employee, has employee-id $eid; $c isa company, has city "London"; $r1(seller: $s, customer: $c) isa sale; Traversal Query
  • 87. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' match $s isa employee, has employee-id $eid; $c isa company, has city "London"; $r1(seller: $s, customer: $c) isa sale; $cd isa customer-demographic, has customer-description 'x'; Traversal Query
  • 88. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' match $s isa employee, has employee-id $eid; $c isa company, has city "London"; $r1(seller: $s, customer: $c) isa sale; $cd isa customer-demographic, has customer-description 'x'; $r2 ($c, $cd); Traversal Query
  • 89. Return all employee IDs who sold to a customer based in London, of customer demographic ‘x’. SELECT Employees.EmployeeID FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID AND Customers.City = 'London' INNER JOIN CustomerCustomerDemo ON Customers.CustomerID = CustomerCustomerDemo.CustomerID INNER JOIN CustomerDemographic ON CustomerCustomerDemo.CustomerTypeId = CustomerDemographic.CustomerTypeId AND CustomerCustomerDemo.CustomerDesc = 'x' match $s isa employee, has employee-id $eid; $c isa company, has city "London"; $r1(seller: $s, customer: $c) isa sale; $cd isa customer-demographic, has customer-description 'x'; $r2 ($c, $cd); get $eid; Traversal Query
  • 95. Type-based Reasoning define organisation sub entity; for-profit sub organisation; non-profit sub organisation; non-profit organisation sub for-profit sub
  • 96. Type-based Reasoning define organisation sub entity; for-profit sub organisation; non-profit sub organisation; bank sub for-profit; pharmaceutical sub for-profit; non-profit organisation sub for-profit bank pharmaceutical sub sub sub
  • 98. Rule-based Reasoning x y z location location
  • 100. Rule-based Reasoning rule transitive-location: when { } then { }; location x y z location location
  • 101. Rule-based Reasoning rule transitive-location: when { (located: $x, locating: $y); (located: $y, locating: $z); } then { }; x y z location location location
  • 102. Rule-based Reasoning rule transitive-location: when { (located: $x, locating: $y); (located: $y, locating: $z); } then { (located: $x, locating: $z); }; x y z location location location
  • 103.
  • 104.
  • 105. Return all the employee IDs who are in a region with region-description ‘x’. SELECT Employee.EmployeeID FROM Employee Rule-based Reasoning
  • 106. Return all the employee IDs who are in a region with region-description ‘x’. SELECT Employee.EmployeeID FROM Employee INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' Rule-based Reasoning
  • 107. Return all the employee IDs who are in a region with region-description ‘x’. SELECT Employee.EmployeeID FROM Employee INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $r isa region, has region-description "x"; Rule-based Reasoning
  • 108. Return all the employee IDs who are in a region with region-description ‘x’. SELECT Employee.EmployeeID FROM Employee INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $e isa employee, has employee-id $eid; $r isa region, has region-description "x"; Rule-based Reasoning
  • 109. Return all the employee IDs who are in a region with region-description ‘x’. SELECT Employee.EmployeeID FROM Employee INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $e isa employee, has employee-id $eid; $r isa region, has region-description "x"; $r1 (located: $e, locating: $r); Rule-based Reasoning
  • 110. Return all the employee IDs who are in a region with region-description ‘x’. SELECT Employee.EmployeeID FROM Employee INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $e isa employee, has employee-id $eid; $r isa region, has region-description "x"; $r1 (located: $e, locating: $r); get $eid; Rule-based Reasoning
  • 111. Rule-based Reasoning Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region- description "x".
  • 112. Rule-based Reasoning Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region- description "x". charities companies
  • 113. Rule-based Reasoning Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region- description "x". charities companies orders orders
  • 114. Rule-based Reasoning Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region- description "x". charities companies orders employee orders employee
  • 115. Rule-based Reasoning Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region- description "x". charities companies territory territory orders employee orders employee
  • 116. Rule-based Reasoning Return all organisation IDs of any type of organisation that employees have sold to who are in a region with region- description "x". charities companies orders orders region ‘x’ territory territory employee employee
  • 117. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies Rule-based Reasoning
  • 118. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' Rule-based Reasoning
  • 119. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION Rule-based Reasoning
  • 120. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' Rule-based Reasoning
  • 121. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $c isa organisation, has org-id $ci; Rule-based Reasoning
  • 122. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $c isa organisation, has org-id $ci; $e isa employee; Rule-based Reasoning
  • 123. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $c isa organisation, has org-id $ci; $e isa employee; $r2 ($c, $e) isa sale; Rule-based Reasoning
  • 124. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $c isa organisation, has org-id $ci; $e isa employee; $r isa region, has region-description "x"; $r2 ($c, $e) isa sale; Rule-based Reasoning
  • 125. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $c isa organisation, has org-id $ci; $e isa employee; $r isa region, has region-description "x"; $r1 (located: $e, locating: $r); $r2 ($c, $e) isa sale; Rule-based Reasoning
  • 126. Return all org IDs any type of customer that employees have sold to who are in a region with region-description "x". SELECT Companies.OrgID FROM Companies INNER JOIN Orders ON Companies.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' UNION SELECT Charities.OrgID FROM Charities INNER JOIN Orders ON Charities.OrgId = Orders.OrgId INNER JOIN Employees ON Orders.OrgId = Employees.OrgId INNER JOIN EmployeeTerritories AS Et ON Employee.EmployeeID = Et.EmployeeID INNER JOIN Territories AS Te ON Te.TerritoryID = Et.TerritoryID INNER JOIN Region AS Re ON Re.RegionDescription = 'x' match $c isa organisation, has org-id $ci; $e isa employee; $r isa region, has region-description "x"; $r1 (located: $e, locating: $r); $r2 ($c, $e) isa sale; get $ci; Rule-based Reasoning
  • 127.
  • 128. Conceptual and Logical Model ER Diagram Normalisation 3NF TypeDB X X X Abstraction Over Logical Model Physical Level
  • 129. A language that you can read and understand intuitively enables you to ask questions at a higher level, while letting the system figure out how to do the lower level operations.
  • 130. Thank you for attending this webinar!