MySQL
MySQL Definition
- The Primary Key constraint uniquely identifies each record in a table. Primary keys must contain UNIQUE values, and cannot contain NULL values.
- The FOREIGN KEY is a field in one table, refers to the PRIMARY KEY of another table.
KEYs
(INDEXes) are defined on certain columns to facilitate fast search on these columns. We would use SHOW INDEX FROM tableName \G
to display the details on indexes.
CREATE INDEX email_index ON Users(email);
MySQL Query
MySQL Explain
- Add
EXPLAIN
before select statement show analyzing how queries are executed.
MySQL vs MongoDB
MySQL |
Mongo DB |
Schema-based |
Schema-less |
Relational DB |
Non-relational DB |
Table-structure system |
Document-based system |
|
Does not gurantee data integrity due lack of relation |