Transferred from: http://www.cnblogs.com/wendingding/p/3868893.html
One, offline caching
In project development, it is usually necessary to deal with the offline cache of data, such as offline caching of news data. Description: Offline caching is typically the case where you save data to a project's sandbox. There are several ways (1) Archive: nscodeing, Nskeyedarchiver (2) Preferences: Nsuserdefaults (3) plist storage: WriteToFile Hint: The three methods above have a fatal disadvantage, It is not possible to store large quantities of data, there is a performance problem. Example: Using the archive Two questions: (1) data access must be complete, require write time to write once, read the time to read all at once, which involves the application of performance issues. (2) If there are 1000 data, at this time to deposit the 1001th piece of data, then need to take all the data out, add this data, and then deposit. Note: The above three technologies cannot handle the storage of large quantities of data, and large quantities of data are usually stored using a database.
Second, SQLite simple introduction
How data is stored in 1.ios
(1) Plist (nsarray\nsdictionary)
(2) Preference (preference setting \nsuserdefaults)
(3) nscoding (Nskeyedarchiver\nskeyedunarchiver)
(4) SQLite3
(5) Core Data
Description
3 is the version number, which is the third version of SQLite. Core data is a package for SQLite because the SQLite used in iOS is a pure C language. 2.SQLite
(1) What is SQLite?
A: SQLite is a lightweight embedded database that is used by both Android and iOS to create a SQLite database
(2) features (advantages)
A: 1) It occupies a very low resource, in the embedded device, may only need hundreds of K of memory is enough
2) It is processed faster than the two famous databases of MySQL and PostgreSQL
(3) What is a database
A: A database is a warehouse that organizes, stores, and manages data in accordance with its structure.
(4) Classification of databases
A: Can be divided into 2 major categories
relational database (Mainstream) and object type database (directly into the memory of the object into the database, compared to the relational database can be very good, inefficient)
(5) What are the common relational databases?
A: PC-side: Oracle, MySQL, SQL Server, Access, DB2, Sybase
Embedded \ Mobile Client: SQLite
(6) How does a database store data?
A: The storage structure of the database is similar to Excel, in tables (table). A table consists of multiple fields (columns, attributes, column), and each row of data in the table is called a record
(7) What is the procedure for storing data in a database?
1) Create a new form (table)
2) Add multiple fields (column, columns, properties)
3) Add multiple rows of records (Row,record, each row holds values for multiple fields)
Third, Navicat
Navicat is a well-known database management software that supports most major databases (including SQLite)
Installation of 1.Navicat
(1) After downloading the software, first open the software
(2) Drag the file into the application copy
(3) Crack version, never open the app, first open Sn.app
(4) Click Patch to find the application path and click Open.
(5) Click Generate to generate the registration code
(6) Click Activate, select File, open
(7) Exit SN, open the installation file, complete the installation
Use of 2.Navicat
Create a new SQLite3 database
To create a new database
Set the location where the database is saved (create a new folder):
After a name, save
Set the name of the database connection
When you are finished, double-click Connect database
Note: The Yangyong is the connection name, not the database, and the main database is connected by yangyong this connection. Several items are tables, views, indexes, triggers, and queries in turn.
Create a new table, set the field name
Save, set the table name (it is recommended to separate the lines by the beginning of T, to show that this is a table)
iOS Development Database Chapter-sqlite Brief Introduction