SlideShare a Scribd company logo
0© 2019, LogMeIn, Inc.
Databases
1© 2019, LogMeIn, Inc.
Databases
• Basics
• Database types
• SQL
• Indexes
• Views
• Stored procedures
• MongoDB
2© 2019, LogMeIn, Inc.
Data
• The data itself doesn’t have any meaning
– 300
– A=25
– Yellow
– [32,12,43,21,55,76,54]
3© 2019, LogMeIn, Inc.
Information
• Data with meaning
– Ferenc is 39 years old
– My neighbor has four black dogs
– My grandfather was ten years older than my grandmother.
– A rose is a woody perennial flowering plant of the genus Rosa, in the
family Rosaceae, or the flower it bears.
4© 2019, LogMeIn, Inc.
Database
• A database is an organized collection of data
5© 2019, LogMeIn, Inc.
Database management system
The database management system (DBMS) is the software that interacts
with end users, applications, and the database itself to capture and analyze
the data.
6© 2019, LogMeIn, Inc.
Relational database system
• A relational database management system (RDBMS) is a database
management system (DBMS) based on the relational model of data.
• The relational model (RM) for database management is an approach to
managing data using a structure and language consistent with first-order
predicate logic, first described in 1969 by English computer scientist Edgar
F. Codd where all data is represented in terms of tuples, grouped into
relations.
7© 2019, LogMeIn, Inc.
RDBMS
Id Title Author Year ISBN10
1 Omerta Mario Puzo 2000 0-434-00870-2
2 The Godfather Mario Puzo 1969 0-399-10342-2
3 Birdy William
Wharton
1979 0-679-73412-0
4 Slaughterhouse-
five
Kurt
Vonnegut
1969 0-7910-9295-X
Id Name Year
1 Zoltan Kovacs 1998
2 Maria Vas 2000
3 Lajos Jo 2014
4 Klara Kis 1979
8© 2019, LogMeIn, Inc.
Relational Database Management Systems
• MySQL
• PostgreSQL
• SQLServer
• Oracle RDBMS
• DB2
• Amazon Aurora
9© 2019, LogMeIn, Inc.
RDBMS’s (Pro)
• SQL is a powerful query language
• There’s a lot’s of relational databases available, with good support
• It’s easy to find a developer with SQL experience
• They’re ACID complaint
– Atomicity
– Consistency
– Isolation
– Durabilty
10© 2019, LogMeIn, Inc.
RDBMS (Con)
• The data has to be stored in a structured way, planning needed
• It’s hard to convert between database tables and real objects
• It’s hard to optimize on scaling, they’re mostly vertically scalable
11© 2019, LogMeIn, Inc.
Non-relational databases (NoSQL)
Relational databases were never designed to cope with the scale and agility
challenges that face modern applications – and aren't built to take
advantage of cheap storage and processing power that's available today
through the cloud. NoSQL tries to solve these problems.
12© 2019, LogMeIn, Inc.
Key – Value store
• Memcached
• Redis
• Amazon DynamoDB
13© 2019, LogMeIn, Inc.
Wide column store
• Apache Cassandra
• Apache HBase
14© 2019, LogMeIn, Inc.
Document Store
• MongoDB
• Couchbase
15© 2019, LogMeIn, Inc.
Graphdb
• Neo4j
16© 2019, LogMeIn, Inc.
Searchengine
• Elasticsearch
• Splunk
• Apache solr
17© 2019, LogMeIn, Inc.
Time series data
• RRDTool
• Prometheus
18© 2019, LogMeIn, Inc.
NoSQL Pros
• Flexibile Scalability
• Stores Massive Amounts of data
• Database maintenance could be easier
• Cheaper to implement
19© 2019, LogMeIn, Inc.
(Cap Theorem)
• The CAP theorem states that it is impossible for a distributed data store to
simultaneously provide more than two out of the following three
guarantees:
– Consistency: Every read receives the most recent write or an error
– Availability: Every request receives a (non-error) response – without the guarantee
that it contains the most recent write
– Partition tolerance: The system continues to operate despite an arbitrary number of
messages being dropped (or delayed) by the network between nodes
20© 2019, LogMeIn, Inc.
NoSQL Cons
• They’re not mature
• Harder to get support
• Business Analytics and Business Intelligence could be harder to
implement
21© 2019, LogMeIn, Inc.
SQL
SELECT b.title
FROM friends f
JOIN books b
ON b.year =
f.year
WHERE f.name
= ‘Klara Kis’
Id Title Author Year ISBN1
0
1 Omerta Mario
Puzo
2000 0-434-
00870-
2
2 The
Godfat
her
Mario
Puzo
1969 0-399-
10342-
2
3 Birdy William
Wharto
n
1979 0-679-
73412-
0
4 Slaught
erhous
e-five
Kurt
Vonneg
ut
1969 0-
7910-
9295-x
Id Name Year
1 Zoltan
Kovacs
1998
2 Maria
Vas
2000
3 Lajos Jo 2014
4 Klara Kis 1979
22© 2019, LogMeIn, Inc.
DDL - Data definition language
• CREATE
• ALTER
• DROP
• TRUNCATE
23© 2019, LogMeIn, Inc.
DQL - Data query language
• SELECT
• FROM
• WHERE
• GROUP BY
• ORDER BY
• HAVING
24© 2019, LogMeIn, Inc.
DML - Data Manipulation Language
• INSERT
• UPDATE
• DELETE
25© 2019, LogMeIn, Inc.
JOIN
• A JOIN clause is used to combine rows from two or more tables, based on
a related column between them.
26© 2019, LogMeIn, Inc.
INNER JOIN
SELECT * FROM friends f JOIN books b
+------+---------------+------+------+------------------+-----------------+------+---------------+
| id | Name | Year | id | Title | Author | Year | ISBN10 |
+------+---------------+------+------+------------------+-----------------+------+---------------+
| 1 | Kovacs Zoltan | 1998 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 |
| 2 | Vas Maria | 2000 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 |
| 3 | Jo Lajos | 2014 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 |
| 4 | Kis Klara | 1979 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 |
| 1 | Kovacs Zoltan | 1998 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 |
| 2 | Vas Maria | 2000 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 |
| 3 | Jo Lajos | 2014 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 |
| 4 | Kis Klara | 1979 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 |
| 1 | Kovacs Zoltan | 1998 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 |
| 2 | Vas Maria | 2000 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 |
| 3 | Jo Lajos | 2014 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 |
| 4 | Kis Klara | 1979 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 |
| 1 | Kovacs Zoltan | 1998 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x |
| 2 | Vas Maria | 2000 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x |
| 3 | Jo Lajos | 2014 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x |
| 4 | Kis Klara | 1979 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x |
+------+---------------+------+------+------------------+-----------------+------+---------------+
27© 2019, LogMeIn, Inc.
LEFT (OUTER) JOIN
mysql> SELECT * FROM friends f LEFT JOIN books b ON b.Year = f.year
+------+---------------+------+------+--------+-----------------+------+---------------+
| id | Name | Year | id | Title | Author | Year | ISBN10 |
+------+---------------+------+------+--------+-----------------+------+---------------+
| 2 | Vas Maria | 2000 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 |
| 4 | Kis Klara | 1979 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 |
| 1 | Kovacs Zoltan | 1998 | NULL | NULL | NULL | NULL | NULL |
| 3 | Jo Lajos | 2014 | NULL | NULL | NULL | NULL | NULL |
+------+---------------+------+------+--------+-----------------+------+---------------+
28© 2019, LogMeIn, Inc.
RIGHT (OUTER) JOIN
mysql> SELECT * FROM friends f RIGHT JOIN books b ON b.year = f.year
+------+-----------+------+------+------------------+-----------------+------+---------------+
| id | Name | Year | id | Title | Author | Year | ISBN10. |
+------+-----------+------+------+------------------+-----------------+------+---------------+
| 2 | Vas Maria | 2000 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 |
| 4 | Kis Klara | 1979 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 |
| NULL | NULL | NULL | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 |
| NULL | NULL | NULL | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x |
+------+-----------+------+------+------------------+-----------------+------+---------------+
29© 2019, LogMeIn, Inc.
SELF JOIN
mysql> SELECT * FROM friends a JOIN friends b;
+------+---------------+------+------+---------------+------+
| id | Name | Year | id | Name | Year |
+------+---------------+------+------+---------------+------+
| 1 | Kovacs Zoltan | 1998 | 1 | Kovacs Zoltan | 1998 |
| 2 | Vas Maria | 2000 | 1 | Kovacs Zoltan | 1998 |
| 3 | Jo Lajos | 2014 | 1 | Kovacs Zoltan | 1998 |
| 4 | Kis Klara | 1979 | 1 | Kovacs Zoltan | 1998 |
| 1 | Kovacs Zoltan | 1998 | 2 | Vas Maria. | 2000 |
| 2 | Vas Maria | 2000 | 2 | Vas Maria | 2000 |
| 3 | Jo Lajos | 2014 | 2 | Vas Maria | 2000 |
| 4 | Kis Klara | 1979 | 2 | Vas Maria | 2000 |
| 1 | Kovacs Zoltan | 1998 | 3 | Jo Lajos | 2014 |
| 2 | Vas Maria | 2000 | 3 | Jo Lajos | 2014 |
| 3 | Jo Lajos | 2014 | 3 | Jo Lajos | 2014 |
| 4 | Kis Klara | 1979 | 3 | Jo Lajos | 2014 |
| 1 | Kovacs Zoltan | 1998 | 4 | Kis Klara. | 1979 |
| 2 | Vas Maria | 2000 | 4 | Kis Klara | 1979 |
| 3 | Jo Lajos | 2014 | 4 | Kis Klara | 1979 |
| 4 | Kis Klara | 1979 | 4 | Kis Klara | 1979 |
+------+---------------+------+------+---------------+------+
30© 2019, LogMeIn, Inc.
Indexes
mysql> SHOW CREATE TABLE neos_largeG
*************************** 1. row ***************************
Table: neos_large
Create Table: CREATE TABLE `neos_large` (
`id` int(11) DEFAULT NULL,
[...]
`ink` double DEFAULT NULL,
`om` double DEFAULT NULL,
`w` double DEFAULT NULL,
KEY `tau` (`tau`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> SELECT COUNT(*) FROM neos_large;
+----------+
| COUNT(*) |
+----------+
| 18254688 |
+----------+
1 row in set (4.04 sec)
31© 2019, LogMeIn, Inc.
Indexes
mysql> SELECT MAX(ink) FROM neos_large;
+-------------------+
| MAX(ink) |
+-------------------+
| 154.3668580789491 |
+-------------------+
1 row in set (5.10 sec)
mysql> ALTER TABLE neos_large ADD INDEX(ink);
Query OK, 0 rows affected (44.76 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> SELECT MAX(ink) FROM neos_large;
+-------------------+
| MAX(ink) |
+-------------------+
| 154.3668580789491 |
+-------------------+
1 row in set (0.00 sec)
32© 2019, LogMeIn, Inc.
Views
mysql> CREATE VIEW neos_ink AS SELECT id, ink FROM neos_large;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM neos_ink LIMIT 5;
+----+---------------------+
| id | ink |
+----+---------------------+
| 1 | 10.82856921420592 |
| 2 | 11.56484503237207 |
| 3 | 9.384537356044309 |
| 4 | 26.68761210417409 |
| 5 | 11.87652956555689 |
+----+---------------------+
5 rows in set (0.00 sec)
33© 2019, LogMeIn, Inc.
Stored procedures
DELIMITER $$
DROP PROCEDURE IF EXISTS duplicate_rows$$
CREATE PROCEDURE duplicate_rows (
IN tablename VARCHAR(255),
IN times INT
)
BEGIN
SET @statement = CONCAT(CONCAT(CONCAT(CONCAT("INSERT INTO ",tablename),"
SELECT * FROM "),tablename),";");
PREPARE stmt FROM @statement;
WHILE times > 0 DO SELECT times as "Remaining";
EXECUTE stmt;
SET times = times - 1;
END WHILE;
DEALLOCATE PREPARE stmt;
END $$
34© 2019, LogMeIn, Inc.
Functions
CREATE FUNCTION circle_area (radius REAL)
RETURNS REAL DETERMINISTIC
RETURN POW(radius,2) * PI();
CREATE FUNCTION circle_circumference (radius REAL)
RETURNS REAL DETERMINISTIC
RETURN radius * 2 * PI();
35© 2019, LogMeIn, Inc.
Triggers
DELIMITER $$
CREATE TRIGGER remove_credit_card
BEFORE INSERT ON users FOR EACH ROW
BEGIN
IF new.credit_card_number = '' THEN
SET credit_card_number = NULL;
END IF;
END
$$
36© 2019, LogMeIn, Inc.
MongoDB
“MongoDB is a document database with the scalability and flexibility that you
want with the querying and indexing that you need”
37© 2019, LogMeIn, Inc.
INSERT
db.konyvek.insert(
[
{ Cim: "Omerta", Szerzo: "Mario Puzo", Ev: 2000, ISBN10:
"0-434-00870-2"},
{ Cim: "The Godfather", Szerzo: "Mario Puzo", Ev: 1969,
ISBN10: "0-399-10342-2"},
{ Cim: "Birdy", Szerzo: "William Wharton", Ev: 1979,
ISBN10: "0-679-73412-0"},
{ Cim: "Slaughterhouse-five", Szerzo: "Kurt Vonnegut ", Ev:
2000, ISBN10: "0-7910-9295-x"}
]
)
38© 2019, LogMeIn, Inc.
Find
> db.konyvek.find(
{Cim: "Slaughterhouse-five"}
)
{ "_id" : ObjectId("5c927003d9e410e1bb9fa583"), "Cim" :
"Slaughterhouse-five", "Szerzo" : "Kurt Vonnegut ", "Ev" :
2000, "ISBN10" : "0-7910-9295-x" }
39© 2019, LogMeIn, Inc.
Update
> db.konyvek.update(
{ISBN10: "0-7910-9295-x"},
{Cim: "Slaughterhouse-five", Szerzo: "Kurt Vonnegut ", Ev:
2000, ISBN10: "0-7910-9295-X"}
)
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" :
1 })
40© 2019, LogMeIn, Inc.
“Schemaless”
> db.konyvek.update({"Cim" : "Slaughterhouse-five", "Szerzo" : "Kurt Vonnegut ",
"Ev" : 1969, "ISBN10" : "0-7910-9295-x"},{"Cim" : "Slaughterhouse-five", "Szerzo"
: "Kurt Vonnegut ", "Ev" : 2000, "ISBN10" : "0-7910-9295-X", ISBN13: "978-0-7910-
9295-8"})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.konyvek.find()
{ "_id" : ObjectId("5c929445345a87cb9fea0bc1"), "Cim" : "Omerta", "Szerzo" :
"Mario Puzo", "Ev" : 2000, "ISBN10" : "0-434-00870-2" }
{ "_id" : ObjectId("5c929445345a87cb9fea0bc2"), "Cim" : "The Godfather", "Szerzo"
: "Mario Puzo", "Ev" : 1969, "ISBN10" : "0-399-10342-2" }
{ "_id" : ObjectId("5c929445345a87cb9fea0bc3"), "Cim" : "Birdy", "Szerzo" :
"William Wharton", "Ev" : 1979, "ISBN10" : "0-679-73412-0" }
{ "_id" : ObjectId("5c929445345a87cb9fea0bc4"), "Cim" : "Slaughterhouse-five",
"Szerzo" : "Kurt Vonnegut ", "Ev" : 1969, "ISBN10" : "0-7910-9295-X", "ISBN13" :
"978-0-7910-9295-8" }

More Related Content

Recently uploaded

writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 

Recently uploaded (20)

writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 

Featured

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Databases

  • 1. 0© 2019, LogMeIn, Inc. Databases
  • 2. 1© 2019, LogMeIn, Inc. Databases • Basics • Database types • SQL • Indexes • Views • Stored procedures • MongoDB
  • 3. 2© 2019, LogMeIn, Inc. Data • The data itself doesn’t have any meaning – 300 – A=25 – Yellow – [32,12,43,21,55,76,54]
  • 4. 3© 2019, LogMeIn, Inc. Information • Data with meaning – Ferenc is 39 years old – My neighbor has four black dogs – My grandfather was ten years older than my grandmother. – A rose is a woody perennial flowering plant of the genus Rosa, in the family Rosaceae, or the flower it bears.
  • 5. 4© 2019, LogMeIn, Inc. Database • A database is an organized collection of data
  • 6. 5© 2019, LogMeIn, Inc. Database management system The database management system (DBMS) is the software that interacts with end users, applications, and the database itself to capture and analyze the data.
  • 7. 6© 2019, LogMeIn, Inc. Relational database system • A relational database management system (RDBMS) is a database management system (DBMS) based on the relational model of data. • The relational model (RM) for database management is an approach to managing data using a structure and language consistent with first-order predicate logic, first described in 1969 by English computer scientist Edgar F. Codd where all data is represented in terms of tuples, grouped into relations.
  • 8. 7© 2019, LogMeIn, Inc. RDBMS Id Title Author Year ISBN10 1 Omerta Mario Puzo 2000 0-434-00870-2 2 The Godfather Mario Puzo 1969 0-399-10342-2 3 Birdy William Wharton 1979 0-679-73412-0 4 Slaughterhouse- five Kurt Vonnegut 1969 0-7910-9295-X Id Name Year 1 Zoltan Kovacs 1998 2 Maria Vas 2000 3 Lajos Jo 2014 4 Klara Kis 1979
  • 9. 8© 2019, LogMeIn, Inc. Relational Database Management Systems • MySQL • PostgreSQL • SQLServer • Oracle RDBMS • DB2 • Amazon Aurora
  • 10. 9© 2019, LogMeIn, Inc. RDBMS’s (Pro) • SQL is a powerful query language • There’s a lot’s of relational databases available, with good support • It’s easy to find a developer with SQL experience • They’re ACID complaint – Atomicity – Consistency – Isolation – Durabilty
  • 11. 10© 2019, LogMeIn, Inc. RDBMS (Con) • The data has to be stored in a structured way, planning needed • It’s hard to convert between database tables and real objects • It’s hard to optimize on scaling, they’re mostly vertically scalable
  • 12. 11© 2019, LogMeIn, Inc. Non-relational databases (NoSQL) Relational databases were never designed to cope with the scale and agility challenges that face modern applications – and aren't built to take advantage of cheap storage and processing power that's available today through the cloud. NoSQL tries to solve these problems.
  • 13. 12© 2019, LogMeIn, Inc. Key – Value store • Memcached • Redis • Amazon DynamoDB
  • 14. 13© 2019, LogMeIn, Inc. Wide column store • Apache Cassandra • Apache HBase
  • 15. 14© 2019, LogMeIn, Inc. Document Store • MongoDB • Couchbase
  • 16. 15© 2019, LogMeIn, Inc. Graphdb • Neo4j
  • 17. 16© 2019, LogMeIn, Inc. Searchengine • Elasticsearch • Splunk • Apache solr
  • 18. 17© 2019, LogMeIn, Inc. Time series data • RRDTool • Prometheus
  • 19. 18© 2019, LogMeIn, Inc. NoSQL Pros • Flexibile Scalability • Stores Massive Amounts of data • Database maintenance could be easier • Cheaper to implement
  • 20. 19© 2019, LogMeIn, Inc. (Cap Theorem) • The CAP theorem states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: – Consistency: Every read receives the most recent write or an error – Availability: Every request receives a (non-error) response – without the guarantee that it contains the most recent write – Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes
  • 21. 20© 2019, LogMeIn, Inc. NoSQL Cons • They’re not mature • Harder to get support • Business Analytics and Business Intelligence could be harder to implement
  • 22. 21© 2019, LogMeIn, Inc. SQL SELECT b.title FROM friends f JOIN books b ON b.year = f.year WHERE f.name = ‘Klara Kis’ Id Title Author Year ISBN1 0 1 Omerta Mario Puzo 2000 0-434- 00870- 2 2 The Godfat her Mario Puzo 1969 0-399- 10342- 2 3 Birdy William Wharto n 1979 0-679- 73412- 0 4 Slaught erhous e-five Kurt Vonneg ut 1969 0- 7910- 9295-x Id Name Year 1 Zoltan Kovacs 1998 2 Maria Vas 2000 3 Lajos Jo 2014 4 Klara Kis 1979
  • 23. 22© 2019, LogMeIn, Inc. DDL - Data definition language • CREATE • ALTER • DROP • TRUNCATE
  • 24. 23© 2019, LogMeIn, Inc. DQL - Data query language • SELECT • FROM • WHERE • GROUP BY • ORDER BY • HAVING
  • 25. 24© 2019, LogMeIn, Inc. DML - Data Manipulation Language • INSERT • UPDATE • DELETE
  • 26. 25© 2019, LogMeIn, Inc. JOIN • A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
  • 27. 26© 2019, LogMeIn, Inc. INNER JOIN SELECT * FROM friends f JOIN books b +------+---------------+------+------+------------------+-----------------+------+---------------+ | id | Name | Year | id | Title | Author | Year | ISBN10 | +------+---------------+------+------+------------------+-----------------+------+---------------+ | 1 | Kovacs Zoltan | 1998 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 | | 2 | Vas Maria | 2000 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 | | 3 | Jo Lajos | 2014 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 | | 4 | Kis Klara | 1979 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 | | 1 | Kovacs Zoltan | 1998 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 | | 2 | Vas Maria | 2000 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 | | 3 | Jo Lajos | 2014 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 | | 4 | Kis Klara | 1979 | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 | | 1 | Kovacs Zoltan | 1998 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 | | 2 | Vas Maria | 2000 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 | | 3 | Jo Lajos | 2014 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 | | 4 | Kis Klara | 1979 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 | | 1 | Kovacs Zoltan | 1998 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x | | 2 | Vas Maria | 2000 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x | | 3 | Jo Lajos | 2014 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x | | 4 | Kis Klara | 1979 | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x | +------+---------------+------+------+------------------+-----------------+------+---------------+
  • 28. 27© 2019, LogMeIn, Inc. LEFT (OUTER) JOIN mysql> SELECT * FROM friends f LEFT JOIN books b ON b.Year = f.year +------+---------------+------+------+--------+-----------------+------+---------------+ | id | Name | Year | id | Title | Author | Year | ISBN10 | +------+---------------+------+------+--------+-----------------+------+---------------+ | 2 | Vas Maria | 2000 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 | | 4 | Kis Klara | 1979 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 | | 1 | Kovacs Zoltan | 1998 | NULL | NULL | NULL | NULL | NULL | | 3 | Jo Lajos | 2014 | NULL | NULL | NULL | NULL | NULL | +------+---------------+------+------+--------+-----------------+------+---------------+
  • 29. 28© 2019, LogMeIn, Inc. RIGHT (OUTER) JOIN mysql> SELECT * FROM friends f RIGHT JOIN books b ON b.year = f.year +------+-----------+------+------+------------------+-----------------+------+---------------+ | id | Name | Year | id | Title | Author | Year | ISBN10. | +------+-----------+------+------+------------------+-----------------+------+---------------+ | 2 | Vas Maria | 2000 | 1 | Omerta | Mario Puzo | 2000 | 0-434-00870-2 | | 4 | Kis Klara | 1979 | 3 | Birdy | William Wharton | 1979 | 0-679-73412-0 | | NULL | NULL | NULL | 2 | The Godfather | Mario Puzo | 1969 | 0-399-10342-2 | | NULL | NULL | NULL | 4 | Slaughterhouse-5 | Kurt Vonnegut | 1969 | 0-7910-9295-x | +------+-----------+------+------+------------------+-----------------+------+---------------+
  • 30. 29© 2019, LogMeIn, Inc. SELF JOIN mysql> SELECT * FROM friends a JOIN friends b; +------+---------------+------+------+---------------+------+ | id | Name | Year | id | Name | Year | +------+---------------+------+------+---------------+------+ | 1 | Kovacs Zoltan | 1998 | 1 | Kovacs Zoltan | 1998 | | 2 | Vas Maria | 2000 | 1 | Kovacs Zoltan | 1998 | | 3 | Jo Lajos | 2014 | 1 | Kovacs Zoltan | 1998 | | 4 | Kis Klara | 1979 | 1 | Kovacs Zoltan | 1998 | | 1 | Kovacs Zoltan | 1998 | 2 | Vas Maria. | 2000 | | 2 | Vas Maria | 2000 | 2 | Vas Maria | 2000 | | 3 | Jo Lajos | 2014 | 2 | Vas Maria | 2000 | | 4 | Kis Klara | 1979 | 2 | Vas Maria | 2000 | | 1 | Kovacs Zoltan | 1998 | 3 | Jo Lajos | 2014 | | 2 | Vas Maria | 2000 | 3 | Jo Lajos | 2014 | | 3 | Jo Lajos | 2014 | 3 | Jo Lajos | 2014 | | 4 | Kis Klara | 1979 | 3 | Jo Lajos | 2014 | | 1 | Kovacs Zoltan | 1998 | 4 | Kis Klara. | 1979 | | 2 | Vas Maria | 2000 | 4 | Kis Klara | 1979 | | 3 | Jo Lajos | 2014 | 4 | Kis Klara | 1979 | | 4 | Kis Klara | 1979 | 4 | Kis Klara | 1979 | +------+---------------+------+------+---------------+------+
  • 31. 30© 2019, LogMeIn, Inc. Indexes mysql> SHOW CREATE TABLE neos_largeG *************************** 1. row *************************** Table: neos_large Create Table: CREATE TABLE `neos_large` ( `id` int(11) DEFAULT NULL, [...] `ink` double DEFAULT NULL, `om` double DEFAULT NULL, `w` double DEFAULT NULL, KEY `tau` (`tau`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql> SELECT COUNT(*) FROM neos_large; +----------+ | COUNT(*) | +----------+ | 18254688 | +----------+ 1 row in set (4.04 sec)
  • 32. 31© 2019, LogMeIn, Inc. Indexes mysql> SELECT MAX(ink) FROM neos_large; +-------------------+ | MAX(ink) | +-------------------+ | 154.3668580789491 | +-------------------+ 1 row in set (5.10 sec) mysql> ALTER TABLE neos_large ADD INDEX(ink); Query OK, 0 rows affected (44.76 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> SELECT MAX(ink) FROM neos_large; +-------------------+ | MAX(ink) | +-------------------+ | 154.3668580789491 | +-------------------+ 1 row in set (0.00 sec)
  • 33. 32© 2019, LogMeIn, Inc. Views mysql> CREATE VIEW neos_ink AS SELECT id, ink FROM neos_large; Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM neos_ink LIMIT 5; +----+---------------------+ | id | ink | +----+---------------------+ | 1 | 10.82856921420592 | | 2 | 11.56484503237207 | | 3 | 9.384537356044309 | | 4 | 26.68761210417409 | | 5 | 11.87652956555689 | +----+---------------------+ 5 rows in set (0.00 sec)
  • 34. 33© 2019, LogMeIn, Inc. Stored procedures DELIMITER $$ DROP PROCEDURE IF EXISTS duplicate_rows$$ CREATE PROCEDURE duplicate_rows ( IN tablename VARCHAR(255), IN times INT ) BEGIN SET @statement = CONCAT(CONCAT(CONCAT(CONCAT("INSERT INTO ",tablename)," SELECT * FROM "),tablename),";"); PREPARE stmt FROM @statement; WHILE times > 0 DO SELECT times as "Remaining"; EXECUTE stmt; SET times = times - 1; END WHILE; DEALLOCATE PREPARE stmt; END $$
  • 35. 34© 2019, LogMeIn, Inc. Functions CREATE FUNCTION circle_area (radius REAL) RETURNS REAL DETERMINISTIC RETURN POW(radius,2) * PI(); CREATE FUNCTION circle_circumference (radius REAL) RETURNS REAL DETERMINISTIC RETURN radius * 2 * PI();
  • 36. 35© 2019, LogMeIn, Inc. Triggers DELIMITER $$ CREATE TRIGGER remove_credit_card BEFORE INSERT ON users FOR EACH ROW BEGIN IF new.credit_card_number = '' THEN SET credit_card_number = NULL; END IF; END $$
  • 37. 36© 2019, LogMeIn, Inc. MongoDB “MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need”
  • 38. 37© 2019, LogMeIn, Inc. INSERT db.konyvek.insert( [ { Cim: "Omerta", Szerzo: "Mario Puzo", Ev: 2000, ISBN10: "0-434-00870-2"}, { Cim: "The Godfather", Szerzo: "Mario Puzo", Ev: 1969, ISBN10: "0-399-10342-2"}, { Cim: "Birdy", Szerzo: "William Wharton", Ev: 1979, ISBN10: "0-679-73412-0"}, { Cim: "Slaughterhouse-five", Szerzo: "Kurt Vonnegut ", Ev: 2000, ISBN10: "0-7910-9295-x"} ] )
  • 39. 38© 2019, LogMeIn, Inc. Find > db.konyvek.find( {Cim: "Slaughterhouse-five"} ) { "_id" : ObjectId("5c927003d9e410e1bb9fa583"), "Cim" : "Slaughterhouse-five", "Szerzo" : "Kurt Vonnegut ", "Ev" : 2000, "ISBN10" : "0-7910-9295-x" }
  • 40. 39© 2019, LogMeIn, Inc. Update > db.konyvek.update( {ISBN10: "0-7910-9295-x"}, {Cim: "Slaughterhouse-five", Szerzo: "Kurt Vonnegut ", Ev: 2000, ISBN10: "0-7910-9295-X"} ) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
  • 41. 40© 2019, LogMeIn, Inc. “Schemaless” > db.konyvek.update({"Cim" : "Slaughterhouse-five", "Szerzo" : "Kurt Vonnegut ", "Ev" : 1969, "ISBN10" : "0-7910-9295-x"},{"Cim" : "Slaughterhouse-five", "Szerzo" : "Kurt Vonnegut ", "Ev" : 2000, "ISBN10" : "0-7910-9295-X", ISBN13: "978-0-7910- 9295-8"}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.konyvek.find() { "_id" : ObjectId("5c929445345a87cb9fea0bc1"), "Cim" : "Omerta", "Szerzo" : "Mario Puzo", "Ev" : 2000, "ISBN10" : "0-434-00870-2" } { "_id" : ObjectId("5c929445345a87cb9fea0bc2"), "Cim" : "The Godfather", "Szerzo" : "Mario Puzo", "Ev" : 1969, "ISBN10" : "0-399-10342-2" } { "_id" : ObjectId("5c929445345a87cb9fea0bc3"), "Cim" : "Birdy", "Szerzo" : "William Wharton", "Ev" : 1979, "ISBN10" : "0-679-73412-0" } { "_id" : ObjectId("5c929445345a87cb9fea0bc4"), "Cim" : "Slaughterhouse-five", "Szerzo" : "Kurt Vonnegut ", "Ev" : 1969, "ISBN10" : "0-7910-9295-X", "ISBN13" : "978-0-7910-9295-8" }