Looking to Database and MySQL and ALL

Yasir
3 min readOct 26, 2020

--

Just Check it if you want to learn DB !

In which language MySQL has been written?

MySQL is written in C and C++ .

What is Workbench ?

Its is a GUI for Handling db .

What is Functional Dependency ?

Functional Dependency (FD) is a constraint that determines the relation of one attribute to another attribute in a Database Management System (DBMS). Functional Dependency helps to maintain the quality of data in the database. It plays a vital role to find the difference between good and bad database design.

What is Normalization?

Normalization is a method of organizing the data in the database which helps you to avoid data redundancy, insertion, update & deletion anomaly. It is a process of analyzing the relation schemas based on their different functional dependencies and primary key .

How to Connect Database with NodeJS App ?

Some Road Map for Learning DB in Depth ?

If you know a bit about SQL , it would help you a lot !

SHOW DATABASE
CREATE DATABASE
USE
SELECT
SELECT DISTINCT
ORDER BY
BYWHERE
AND , OR , NOT , ALL , ANY
INSERT INTO
UPDATE
DELETE
MIN MAX
LIKE
IN
BETWEEN
ALIASES
JOINSOR
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN
SELF JOIN
UNION
GROUP BY
HAVING

Examples :

SELECT * FROM movies;
# This command will give you all the columns from movies .
SELECT name,year FROM movies;
# You will get name and year from movies table
SELECT name,rankscore FROM movies LIMIT 20;
# Limit 20 will let you see first 20 Results of the command
SELECT name,rankscore FROM movies LIMIT 20 OFFSET 40;
# Offset will let you skip first 40 results
SELECT name,rankscore,year FROM movies ORDER BY year DESC LIMIT 10;
# ordered is ascending by default
SELECT name,rankscore,year FROM movies ORDER BY year LIMIT 10;SELECT DISTINCT genre FROM movies_genres;
# Distinct will give you unique results
SELECT DISTINCT first_name, last_name FROM directors;SELECT name,year,rankscore FROM movies WHERE rankscore>9 ;
# Where is to set some condtions
SELECT name,year,rankscore FROM movies WHERE rankscore>9 ORDER BY rankscore DESC LIMIT 20;SELECT * FROM movies_genres WHERE genre <> 'Horror';
# "<>" is equal to "!="
SELECT name,year,rankscore FROM movies WHERE rankscore IS NULL LIMIT 20;
# Null mean does not exist
SELECT name,year,rankscore FROM movies WHERE rankscore IS NOT NULL LIMIT 20;SELECT name,year,rankscore FROM movies WHERE rankscore>9 AND year>2000;SELECT name,year,rankscore FROM movies WHERE NOT year<=2000 LIMIT 20;SELECT name,year,rankscore FROM movies WHERE rankscore>9 OR year>2007;SELECT name,year,rankscore FROM movies WHERE year BETWEEN 1999 AND 2000;SELECT name,year,rankscore FROM movies WHERE year BETWEEN 2000 AND 1999;SELECT director_id, genre FROM directors_genres WHERE genre IN ('Comedy','Horror');SELECT MIN(year) FROM movies;SELECT MAX(year) FROM movies;SELECT COUNT(*) FROM movies;SELECT COUNT(*) FROM movies where year>2000;SELECT COUNT(year) FROM movies;SELECT year, COUNT(year) FROM movies GROUP BY year;
# Grouped by will give numbers of movies realsed per year
SELECT year, COUNT(year) FROM movies GROUP BY year ORDER BY year;SELECT year, COUNT(year) year_count FROM movies GROUP BY year ORDER BY year_count;SELECT year, COUNT(year) year_count FROM movies GROUP BY year HAVING year_count>1000;SELECT name, year FROM movies HAVING year>2000;SELECT year, COUNT(year) year_count FROM movies WHERE rankscore>9 GROUP BY year HAVING year_count>20;INSERT INTO movies(id, name, year, rankscore) VALUES (412321, 'Thor', 2011, 7), (412322, 'Iron Man', 2008, 7.9), (412323, 'Iron Man 2', 2010, 7);UPDATE <TableName> SET col1=val1, col2=val2 WHERE conditionUPDATE movies SET rankscore=9 where id=412321;DELETE FROM movies WHERE id=412321;CREATE TABLE language ( id INT PRIMARY, lang VARCHAR(50) NOT NULL);

--

--

Yasir
Yasir

Written by Yasir

Exploring Swift, SwiftUI, and Apple Universe.

No responses yet