1599933600
Structured Query Language (SQL) is famously known as the romance language of data. Even thinking of extracting the single correct answer from terabytes of relational data seems a little overwhelming. So understanding the logical flow of query is very important.
Photo by Glenn Carstens-Peters on Unsplash
SQL is a declarative language, this means SQL query logically describes the question to the SQL Query Optimizer which later decides on the best way to physically execute the query. This method of execution is called the query execution plan. There can be more than one execution plan, so when we say optimize a query that in turn referring to make the query execution plan more efficient.
#data-science #sql #data-analyst #data-analysis #database
1594369800
SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.
Models for SQL exist. In any case, the SQL that can be utilized on every last one of the major RDBMS today is in various flavors. This is because of two reasons:
1. The SQL order standard is genuinely intricate, and it isn’t handy to actualize the whole standard.
2. Every database seller needs an approach to separate its item from others.
Right now, contrasts are noted where fitting.
#programming books #beginning sql pdf #commands sql #download free sql full book pdf #introduction to sql pdf #introduction to sql ppt #introduction to sql #practical sql pdf #sql commands pdf with examples free download #sql commands #sql free bool download #sql guide #sql language #sql pdf #sql ppt #sql programming language #sql tutorial for beginners #sql tutorial pdf #sql #structured query language pdf #structured query language ppt #structured query language
1621850444
When working in the SQL Server, we may have to check some other databases other than the current one which we are working. In that scenario we may not be sure that does we have access to those Databases?. In this article we discuss the list of databases that are available for the current logged user in SQL Server
#sql server #available databases for current user #check database has access #list of available database #sql #sql query #sql server database #sql tips #sql tips and tricks #tips
1620633584
In SSMS, we many of may noticed System Databases under the Database Folder. But how many of us knows its purpose?. In this article lets discuss about the System Databases in SQL Server.
Fig. 1 System Databases
There are five system databases, these databases are created while installing SQL Server.
#sql server #master system database #model system database #msdb system database #sql server system databases #ssms #system database #system databases in sql server #tempdb system database
1603760400
This article will introduce the concept of SQL recursive. Recursive CTE is a really cool. We will see that it can often simplify our code, and avoid a cascade of SQL queries!
The recursive queries are used to query hierarchical data. It avoids a cascade of SQL queries, you can only do one query to retrieve the hierarchical data.
First, what is a CTE? A CTE (Common Table Expression) is a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. For example, you can use CTE when, in a query, you will use the same subquery more than once.
A recursive CTE is one having a subquery that refers to its own name!
Recursive CTE is defined in the SQL standard.
A recursive CTE has this structure:
In this example, we use hierarchical data. Each row can have zero or one parent. And it parent can also have a parent etc.
Create table test (id integer, parent_id integer);
insert into test (id, parent_id) values (1, null);
insert into test (id, parent_id) values (11, 1);
insert into test (id, parent_id) values (111, 11);
insert into test (id, parent_id) values (112, 11);
insert into test (id, parent_id) values (12, 1);
insert into test (id, parent_id) values (121, 12);
For example, the row with id 111 has as ancestors: 11 and 1.
Before knowing the recursive CTE, I was doing several queries to get all the ancestors of a row.
For example, to retrieve all the ancestors of the row with id 111.
While (has parent)
Select id, parent_id from test where id = X
With recursive CTE, we can retrieve all ancestors of a row with only one SQL query :)
WITH RECURSIVE cte_test AS (
SELECT id, parent_id FROM test WHERE id = 111
UNION
SELECT test.id, test.parent_id FROM test JOIN cte_test ON cte_test.id = test.parent_id
) SELECT * FROM cte_test
Explanations:
It indicates we will make recursive
It is the initial query.
It is the recursive expression! We make a jointure with the current CTE!
Replay this example here
#sql #database #sql-server #sql-injection #writing-sql-queries #sql-beginner-tips #better-sql-querying-tips #sql-top-story
1597214640
For starters, this open-source project garners 11k weekly downloads off npm and has over 5K stars on GitHub.
I was surprised to see that there aren’t more posts about this popular lightweight client-side in-memory SQL database online apart from this awesome article I found. However, AlaSQL’s website gets straight to the point:
What’s not to love? AlaSQL was designed to work in browser and Node.js, is fast, and super easy to use. Some say that when you need to find data fast and want a better alternative to a full database or Redis, check out AlaSQL.
HarperDB has had the pleasure of using AlaSQL for its backend SQL functionality. We chose to use AlaSQL because it has extensive language support, is well supported and extensible, can execute SQL against data sets (JSON or Arrays), and the ability to generate reusable functions. AlaSQL enables us to convert SQL language into an Abstract Syntax Tree (AST) that we can programmatically interpret into our data model. We can feed data into a processor that can perform the calculations native to SQL, using the functions defined in the library throughout our project as APIs and not just in the context of a SQL call.
AlaSQL is extensible and allows us to create custom functions. For example, we created a custom function called SEARCH_JSON that allows HarperDB users to search and transform nested documents. This function wraps a popular npm package called JSONata. With AlaSQL we were able to embed another open-source package as a simple function call. Our implementation was as easy as defining the function (Note this is sample code):
Java
1
const jsonata = require('jsonata');
2
/**
3
* wrapper function that implements the JSONata library, which performs searches, transforms, etc... on JSON
4
* @param {String} jsonata_expression - the JSONata expression to execute
5
* @param {any} data - data which will be evaluated
6
* @returns {any}
7
*/
8
function searchJSON(jsonata_expression, data){
9
if(typeof jsonata_expression !== 'string' || jsonata_expression.length === 0){
10
throw new Error('search json expression must be a non-empty string');
11
}
12
13
let alias = '__' + jsonata_expression + '__';
14
15
if(hdb_utils.isEmpty(this.__ala__.res)){
16
this.__ala__.res = {};
17
}
18
19
if(hdb_utils.isEmpty(this.__ala__.res[alias])) {
20
let expression = jsonata(jsonata_expression);
21
this.__ala__.res[alias] = expression;
22
}
23
return this.__ala__.res[alias].evaluate(data);
24
}
25
//Then define a custom function in AlaSQL:
26
const alasql = require('alasql');
27
alasql.fn.search_json = alasql.fn.SEARCH_JSON = searchJSON;
We are happy with our decision to use AlaSQL to interpret SQL into our data model and run performant queries against as much SQL as possible. That’s why we hosted the creators of AlaSQL on June 16th for a showcase to get an inside look at how AlaSQL was created, how it grew in popularity, and real-world use cases and products. It was awesome to hear from AlaSQL creators Mathias Rangel Wulff and Andrey Gershun. After Q&A on AlaSQL, our CTO Kyle Bernhardy shared more about using AlaSQL as HarperDB’s engine to interpret and parse complex SQL into our data model and perform simple to complex SQL CRUD operations, as well as exposing other libraries like Turf.js, JSONata and more.
Looking for more resources on this innovative client-side in-memory SQL database? Check out this JavaScript library designed for:
#database #sql #databases #sql (structured query language) #database applications #code activation #sql aggregation