MySQL
What is MySQL?
MySQL is a relational database. Data sits in rows and columns. One table can be a user, another an order. A shared number ties the rows. The server started in the open in 1995. It is now a product of the Oracle company. MariaDB is a close branch of it, not the same thing.
What is MySQL used for?
MySQL is for keeping a site's user, post, and order. A program sends a query, and the server returns rows.
- Storing a user name and a password hash
- A list of articles
- Tying an order to a product
- The same query answered for many people
What can you do with MySQL?
With MySQL you add a row, choose by a condition, update, and delete. An index can speed a search, but an index on every column is not right. The server does not draw the page itself. Another program draws the page.
Is MySQL hard to learn?
Opening a table is easy. The difficulty is the relation and the delete condition. UPDATE or DELETE without a condition changes many rows. Pasting user text into the query opens injection. What is stored is not the password itself, but a trace of it.
Advantages and limits
Advantage: a table is clear, SQL is a language many people know, and a backup stays on one server. Limit: it does not fit every text file. A query with many joins slows down when it is built wrong. MySQL is not the only database.
Basic ideas
A table is the names of the columns. A row is one record. A key is for finding that row alone.
- SELECT chooses rows
- INSERT adds a row
- WHERE keeps the condition
- JOIN ties two tables by a number
A short example
This query chooses one user by name. The name is not pasted into the text. The program sends it as a separate parameter.
SELECT id, name FROM users WHERE name = ?;
Common questions
- Are MySQL and SQL the same? No. SQL is the query language. MySQL is the server that runs that query.
- Is the password written in the open in the table? No. What is stored is a trace of it, not the text itself.
- Is MySQL a site? No. It stores data. Another program shows the page.