Initial configuration guide for SQLite in IOS application development _ios

Source: Internet
Author: User
Tags sqlite

iOS Development Database Chapter-sqlite Brief Introduction

One, offline caching

In project development, it is usually necessary to process the data off-line, such as off-line caching of news data.
Note: Offline caching is generally to save data to the project's sandbox. There are several ways to do this
(1) Archiving: nscodeing, Nskeyedarchiver
(2) Preferences: Nsuserdefaults
(3) plist storage: WriteToFile
Tip: All three of these methods have a fatal disadvantage, that is, can not store large quantities of data, there are performance problems.
Example: Using an archive

Two questions:
(1) Access to the data must be complete, required to write a one-time write, read the time to read all, this involves the application of performance issues.
(2) If there are 1000 data, then the 1001th data should be deposited, then all the data need to be taken out, the data added to the after, and then deposited.
Note: The above three technologies are not able to handle the storage of large amounts of data, and large quantities of data are usually stored using databases.

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 and is the third version of SQLite.
Core data is the encapsulation of SQLite, because the SQLite used in iOS is pure C language.
2.SQLite
(1) What is SQLite?

A: SQLite is a lightweight, embedded database, and Android and iOS are all developed using SQLite databases.

(2) features (advantages)

A: 1 It occupies a very low resource, in embedded devices, may only need hundreds of K of memory is enough

2 its processing speed than MySQL, PostgreSQL these two well-known database are also fast

(3) What is a database

A: Databases (database) are warehouses that organize, store, and manage data according to data structures

(4) Classification of databases

Answer: Can be divided into 2 kinds

relational database (Mainstream) and object-oriented database (directly into the memory of the object into the database, compared to relational database can be very good, inefficient)

(5) What are the common relational databases?

Answer: PC-side: Oracle, MySQL, SQL Server, Access, DB2, Sybase

Embedded \ Mobile Client: SQLite

(6) How does the database store the data?

A: The storage structure of the database is similar to Excel, in tables (table). Tables consist of multiple fields (columns, properties, column), and each row of data in a table is called a record

(7) The steps of the database to store data?

1 A new table (table)

2 Add multiple fields (column, columns, properties)

3 Add Multiline records (Row,record, each row holds multiple fields corresponding to the value)

Third, Navicat

Navicat is a well-known database management software, supporting most of the mainstream database (including SQLite)

Installation of 1.Navicat

(1) After downloading the software, first open the software

(2) Drag the file into the application copy

(3) Cracked version, do not open the app, first open Sn.app

(4) Click Patch, find the application path, click Open.

(5) Click Generate, Generate registration code

(6) Click Activate, select File, open

(7) Exit SN, open installation file, complete 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 is saved

Set the name of a database connection

When you are done, double-click the connection database

Note: The Yangyong is the connection name, not the database, and the main database is connected using the Yangyong connection. Several items are tables, views, indexes, triggers, and queries in turn.

Create a new table, set the field name

Save, set table name (it is recommended that the T begin with an underscore to differentiate, indicating that this is a table)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.