sql Flashcards
Standard numerical operators
=, !=, < <=, >, >=
Number is [not] within range of two values (inclusive)
… WHERE col_name [NOT] BETWEEN … AND …;
Number exists in a list
… WHERE col_name IN (2, 4, 6);
Number does not exist in a list
… WHERE col_name NOT IN (1, 3, 5);
Case sensitive exact string [inequality] comparison
… WHERE col_name [!]= “abc”;
Case insensitive exact string [inequality] comparison
… WHERE col_name [NOT] LIKE “abc”;
Match a single character
… WHERE col_name [NOT] LIKE “_bc”;
String [does not] exists in a list
… WHERE col_name [NOT] IN (“A”, “B”, “C”);
Match a sequence of zero or more characters
… WHERE col_name [NOT] LIKE “%abc”;
Database normalization is useful because
minimizes duplicate data in any single table, and allows for data in the database to grow independently of each other
Database normalization is useful because
minimizes duplicate data in any single table, and allows for data in the database to grow independently of each other
Database normalization trade-off
Queries get slightly more complex since they have to be able to find data from different parts of the database, and performance issues can arise when working with many large tables.
inner join - only contains data that belongs in both of the tables
SELECT title, domestic_sales, international_sales
FROM movies
INNER JOIN boxoffice ON movies.id=boxoffice.movie_id;
Stored procedure
Create once, store and call for several times whenever it is required, it can be executed only in the database and utilizes more memory in the database server.
A view
A virtual table, Restricting access to data, Making complex queries simple.