Skip to content

Commit 020fd02

Browse files
markdown source builds
Auto-generated via `{sandpaper}` Source : 725be22 Branch : main Author : alexthrelkeld <127440629+alexthrelkeld@users.noreply.github.com> Time : 2026-03-27 12:41:27 +0000 Message : Simplified data-type table in first episode (#385) * simplified data type table * improve descriptions in episode 1 data types table * added data type quick reference table to cheat sheet * Validation and clean-up of types in different database system * Final fixes with references to vendor documentation --------- Co-authored-by: James Foster <James.Foster@csiro.au>
1 parent d46bef2 commit 020fd02

3 files changed

Lines changed: 78 additions & 58 deletions

File tree

00-sql-introduction.md

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -201,28 +201,28 @@ follow these instructions:
201201
10. 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).
202202
11. 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

md5sum.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"NEWS.md" "84aa522251c8b0043f12e83af45cc3d8" "site/built/NEWS.md" "2023-04-21"
66
"config.yaml" "0928fbefeca4f51e54ccc3687a9565e9" "site/built/config.yaml" "2023-04-21"
77
"index.md" "cfdee7444b27a96171c25e1d4915e1e9" "site/built/index.md" "2023-06-07"
8-
"episodes/00-sql-introduction.md" "e8ac248b290e74c264817c41dbbad159" "site/built/00-sql-introduction.md" "2024-09-11"
8+
"episodes/00-sql-introduction.md" "0fd75012237675c81afcfb7c031f3c2b" "site/built/00-sql-introduction.md" "2026-03-27"
99
"episodes/01-sql-basic-queries.md" "256c3e6db6f844897ae9643129609c31" "site/built/01-sql-basic-queries.md" "2024-09-11"
1010
"episodes/02-sql-aggregation.md" "a96fd0f658c942678d1bf91848eb151c" "site/built/02-sql-aggregation.md" "2026-03-18"
1111
"episodes/03-sql-joins.md" "4dc3bf7005bec72c79e1a7663fdbcd2c" "site/built/03-sql-joins.md" "2026-03-18"
1212
"instructors/instructor-notes.md" "105728ef72c768e968ca9d11c2a14109" "site/built/instructor-notes.md" "2023-04-21"
1313
"learners/discuss.md" "0ff402a01b3496a37bf790b8eae69b76" "site/built/discuss.md" "2024-09-11"
1414
"learners/reference.md" "83dc790413398fce3bb07518546928fa" "site/built/reference.md" "2023-10-19"
1515
"learners/setup.md" "ee35c0e736db51a50f60d4c4d1fe44f6" "site/built/setup.md" "2024-09-11"
16-
"learners/sql-cheat-sheet.md" "fe94973871efccd88f8bc193d359bdb1" "site/built/sql-cheat-sheet.md" "2023-10-19"
16+
"learners/sql-cheat-sheet.md" "161859e4293e68b70b2f0664e2bce359" "site/built/sql-cheat-sheet.md" "2026-03-27"
1717
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2023-04-21"

0 commit comments

Comments
 (0)