@@ -201,28 +201,28 @@ follow these instructions:
20120110 . In the center panel of the window that appears, set the data types for each field using the suggestions in the table below (this includes fields from the ` plots ` and ` species ` tables also).
20220211 . Finally, click ** OK** one more time to confirm the operation. Then click the ** Write Changes** button to save the database.
203203
204- | Field | Data Type | Motivation | Table(s) |
205- | ----------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ---------------- |
206- | day | INTEGER | Having data as numeric allows for meaningful arithmetic and comparisons | surveys |
207- | genus | TEXT | Field contains text data | species |
208- | hindfoot\_ length | REAL | Field contains measured numeric data | surveys |
209- | month | INTEGER | Having data as numeric allows for meaningful arithmetic and comparisons | surveys |
210- | plot\_ id | INTEGER | Field contains numeric data | plots, surveys |
211- | plot\_ type | TEXT | Field contains text data | plots |
212- | record\_ id | INTEGER | Field contains numeric data | surveys |
213- | sex | TEXT | Field contains text data | surveys |
214- | species\_ id | TEXT | Field contains text data | species, surveys |
215- | species | TEXT | Field contains text data | species |
216- | taxa | TEXT | Field contains text data | species |
217- | weight | REAL | Field contains measured numerical data | surveys |
218- | year | INTEGER | Allows for meaningful arithmetic and comparisons | surveys |
204+ | Field | Data Type | Motivation | Table(s) |
205+ | ----------------------------------------------------- | :----------------------- | ----------------------------------------------------------------------- | ---------------- |
206+ | day | INTEGER | Having data as numeric allows for meaningful arithmetic and comparisons | surveys |
207+ | genus | TEXT | Field contains text data | species |
208+ | hindfoot\_ length | REAL | Field contains measured numeric data | surveys |
209+ | month | INTEGER | Having data as numeric allows for meaningful arithmetic and comparisons | surveys |
210+ | plot\_ id | INTEGER | Field contains numeric data | plots, surveys |
211+ | plot\_ type | TEXT | Field contains text data | plots |
212+ | record\_ id | INTEGER | Field contains numeric data | surveys |
213+ | sex | TEXT | Field contains text data | surveys |
214+ | species\_ id | TEXT | Field contains text data | species, surveys |
215+ | species | TEXT | Field contains text data | species |
216+ | taxa | TEXT | Field contains text data | species |
217+ | weight | REAL | Field contains measured numerical data | surveys |
218+ | year | INTEGER | Allows for meaningful arithmetic and comparisons | surveys |
219219
220220::::::::::::::::::::::::::::::::::::::: challenge
221221
222222### Challenge
223223
224224- Import the ` plots ` and ` species ` tables
225-
225+
226226
227227::::::::::::::::::::::::::::::::::::::::::::::::::
228228
@@ -235,46 +235,16 @@ You can also use this same approach to append new fields to an existing table.
235235
236236### Data types {#datatypes}
237237
238- | Data type | Description |
239- | ----------------------------------------------------- | :------------------------------------------------------------------------------------------------------- |
240- | CHARACTER(n) | Character string. Fixed-length n |
241- | VARCHAR(n) or CHARACTER VARYING(n) | Character string. Variable length. Maximum length n |
242- | BINARY(n) | Binary string. Fixed-length n |
243- | BOOLEAN | Stores TRUE or FALSE values |
244- | VARBINARY(n) or BINARY VARYING(n) | Binary string. Variable length. Maximum length n |
245- | INTEGER(p) | Integer numerical (no decimal). |
246- | SMALLINT | Integer numerical (no decimal). |
247- | INTEGER | Integer numerical (no decimal). |
248- | BIGINT | Integer numerical (no decimal). |
249- | DECIMAL(p,s) | Exact numerical, precision p, scale s. |
250- | NUMERIC(p,s) | Exact numerical, precision p, scale s. (Same as DECIMAL) |
251- | FLOAT(p) | Approximate numerical, mantissa precision p. A floating number in base 10 exponential notation. |
252- | REAL | Approximate numerical |
253- | FLOAT | Approximate numerical |
254- | DOUBLE PRECISION | Approximate numerical |
255- | DATE | Stores year, month, and day values |
256- | TIME | Stores hour, minute, and second values |
257- | TIMESTAMP | Stores year, month, day, hour, minute, and second values |
258- | INTERVAL | Composed of a number of integer fields, representing a period of time, depending on the type of interval |
259- | ARRAY | A set-length and ordered collection of elements |
260- | MULTISET | A variable-length and unordered collection of elements |
261- | XML | Stores XML data |
262-
263- ### SQL Data Type Quick Reference {#datatypediffs}
264-
265- Different databases offer different choices for the data type definition.
266-
267- The following table shows some of the common names of data types between the various database platforms:
268-
269- | Data type | Access | SQLServer | Oracle | MySQL | PostgreSQL |
270- | :---------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------- | :--------------- | :------------ | :------------ |
271- | boolean | Yes/No | Bit | Byte | N/A | Boolean |
272- | integer | Number (integer) | Int | Number | Int / Integer | Int / Integer |
273- | float | Number (single) | Float / Real | Number | Float | Numeric |
274- | currency | Currency | Money | N/A | N/A | Money |
275- | string (fixed) | N/A | Char | Char | Char | Char |
276- | string (variable) | Text (\< 256) / Memo (65k+) | Varchar | Varchar2 | Varchar | Varchar |
277- | binary object OLE Object Memo Binary (fixed up to 8K) | Varbinary (\< 8K) | Image (\< 2GB) Long | Raw Blob | Text Binary | Varbinary |
238+ SQLite has four data types, shown in the table below.
239+
240+ | Data type | Description |
241+ | ------------------ | :-------------------------------------------------------------------------------------------------------------------- |
242+ | TEXT | Text string |
243+ | INTEGER | Integer (positive or negative whole number) |
244+ | REAL | Approximate numerical value (floating point number) |
245+ | BLOB | General data with no specfic type, stored in the database exactly as given (stands for _ Binary Large OBject_ ) |
246+
247+ In addition to these four data types, SQLite has a NULL value for missing data. We will talk more about dealing with missing data in Episode 3.
278248
279249:::::::::::::::::::::::::::::::::::::::: keypoints
280250
0 commit comments