SQL is a standard language for storing, manipulating and retrieving data in Databasee.
Relational database: RDBMS (relational database mangement System)
SQLite3 :
The Rails default lightweight database, integrated in rails, is db/development.sqlite3 in this file.
Use: Single use. So when the actual deployment will be replaced by MySQL and other database server.
Mysql:
The current popular open source database. This is a database server, to connect it requires the database account password.
Install MySQL on Mac with Brew install MySQL , we recommend installing Sequal Pro gui (graphical user interface, GUI) software
If someone asks you how the database works, tell him to read this article.http://blog.jobbole.com/100349/
Some learning materials:
https://www.udacity.com/course/intro-to-relational-databases--ud197
Https://launchschool.com/books/sql/read/introduction
Https://www.codecademy.com/learn/learn-sql
Https://www.codecademy.com/learn/sql-analyzing-business-metrics
Https://en.wikibooks.org/wiki/SQL_Exercises
https://pgexercises.com/
Http://sqlzoo.net/wiki/SQL_Tutorial
Features of the RDBMS:
schema: Define tables and columns before use, and define the data Type for each column.
Data Type:
varchar or text:
Integer,decimal,float:
Blob binary: can be stored in a file. However, it is usually not recommended to plug the file directly into the database, the database plug is too large to backup and management, and secondly, there is no benefit, because you also can not be used for binary files search and filter. People are also mentally prepared to read files slowly. So usually only in the database records metadata such as file name, size, MimeType and so on, and the actual file is placed on the file system, or uploaded to seven cattle or AWS S3 space.
Boolean:
Date, Time, Datetime:
Pasting
create_table : Events Do |T| T.string : Name T.text :d escription T.integer : Capacity T.integer : user_id, : null = false//This is limited to constraint, here is not empty;
most of the validation is typically placed in rails model, which is more resilient and hard to skip in the DB layer. t. Timestamps End
Two-SQL standard language (structured Query language)
All relational databases use SQL's Structured Query language to manipulate database.for example:
1. INSERT into Events VALUES ("rubyconf", 100); Insert a piece of data into the events table
2. SELECT * from events; Take out all the data
Tri ACID (4 properties)
Transaction: A process of doing business. Package a set of actions to execute together. Use begin;...commit; it can guarantee the correctness of data access, either succeed together or fail together.
Atomicity: A transaction is an atom.
Consistency: Consistency ensures that the integrity of the database before and after the transaction is not compromised.
Isolation: Isolation: The database allows multiple concurrent transaction to be carried out simultaneously without interference.
Durability Persistence: The modification of data is permanent.
These 4 characteristics, so that the relational database in the multi-person connection to operate the database when the data is guaranteed?
Basic SQL Learning: and deep learning materials