Add new challenges

feat/course
Kamran Ahmed 3 weeks ago
parent 7f60f1301e
commit 8369f01d99
  1. 40
      src/data/courses/sql/chapters/data-definition-language/lessons/constraints-challenge.md
  2. 31
      src/data/courses/sql/chapters/data-definition-language/lessons/data-types-challenge.md
  3. 2
      src/data/courses/sql/chapters/data-definition-language/lessons/data-types-in-sqlite.md
  4. 27
      src/data/courses/sql/chapters/data-definition-language/lessons/simple-table-creation.md
  5. 32
      src/data/courses/sql/chapters/data-definition-language/lessons/table-creation.md
  6. 15
      src/styles/global.css

@ -0,0 +1,40 @@
---
title: Constraints Challenge
description: Create a table for bookstore inventory using various SQL constraints
order: 320
type: challenge
initSteps: []
expectedResults:
- columns: [message]
values:
- ['Table created successfully']
---
You need to create a table named `book_inventory` for a bookstore system. The table should track detailed information about books using appropriate data types and constraints listed below.
| Column | Data Type | Constraints |
| ------------ | ---------------- | -------------------------------------------- |
| id | `INTEGER` | Primary Key |
| isbn | `VARCHAR(13)` | Null values not allowed and must be unique |
| title | `VARCHAR(200)` | Null values not allowed |
| author | `VARCHAR(100)` | Null values not allowed |
| price | `DECIMAL(10, 2)` | Null values not allowed and must be positive |
| pages | `INTEGER` | Must be positive |
| in_stock | `BOOLEAN` | Not null and default true |
| publish_year | `INTEGER` | Not null |
| last_updated | `TIMESTAMP` | Not null and default `CURRENT_TIMESTAMP` |
## Expected Output
After executing your query, the table should be created successfully with all specified columns and constraints.
## Notes
This challenge tests your knowledge of:
- SQL data types (INTEGER, VARCHAR, DECIMAL, BOOLEAN, DATE, TIMESTAMP)
- Primary key and unique constraints
- NOT NULL constraints
- DEFAULT values
- CHECK constraints for data validation
- Working with date and time data types

@ -0,0 +1,31 @@
---
title: Data Types Challenge
description: Create a table for bookstore inventory using appropriate SQL data types
order: 310
type: challenge
initSteps: []
expectedResults:
- columns: [message]
values:
- ['Table created successfully']
---
You need to create a table named `book_inventory` for a bookstore system. The table should track detailed information about books using appropriate data types.
| Column | Description |
| ---------------- | ---------------------------------------------- |
| id | Whole numbers for identification (Primary Key) |
| isbn | Text of exactly 13 characters |
| title | Variable-length text up to 200 characters |
| author | Variable-length text up to 100 characters |
| price | Number with 2 decimal places and precision 10 |
| pages | Whole number |
| in_stock | True/False value |
| publication_date | Date only (no time) |
| last_updated | Date and time together |
The only constraint you need to implement is that the `id` column should be a primary key. Apart from that, you are only being tested on the data types.
## Expected Output
After executing your query, the table should be created successfully with all specified columns using appropriate data types.

@ -50,7 +50,7 @@ The output will be:
| --- | -------- | ----------- | | --- | -------- | ----------- |
| 1 | John Doe | Twenty Five | | 1 | John Doe | Twenty Five |
You should also note that SQLite supports only a few data types: `INTEGER`, `REAL`, `TEXT`, `BLOB`, and `NULL`. Other data types such as `DECIMAL`, `FLOAT`, `VARCHAR`, etc., are not supported, although it will not complain if you try to assign them to a column. You should also note that SQLite supports only a few data types: `INTEGER`, `REAL`, `TEXT`, `BLOB`, and `NULL`. Other data types such as  `DECIMAL`, `FLOAT`, `VARCHAR`, etc., are not supported, although it will not complain if you try to assign them to a column.
For more details, check the [SQLite data types](https://www.sqlite.org/datatype3.html) and [why it uses dynamic typing](https://www.sqlite.org/flextypegood.html) in the official documentation. For more details, check the [SQLite data types](https://www.sqlite.org/datatype3.html) and [why it uses dynamic typing](https://www.sqlite.org/flextypegood.html) in the official documentation.

@ -0,0 +1,27 @@
---
title: Simple Table Creation
description: Write a SQL query to create a `books` table with specific columns.
order: 300
type: challenge
initSteps: []
expectedResults:
- columns: [message]
values:
- ['Table created successfully']
---
You are required to create a table named `books` for a bookstore database. The table should have the following columns:
| Column Name | Data Type |
| -------------- | -------------- |
| id | `INTEGER` |
| title | `VARCHAR(250)` |
| author | `VARCHAR(250)` |
| genre | `VARCHAR(250)` |
| published_date | `DATE` |
Create a simple table with these columns using basic data types.
## Expected Output
After executing the query, there should be no errors and the table should be created successfully. You can verify the schema under the `Schema` tab.

@ -1,32 +0,0 @@
---
title: Table Creation
description: Write a SQL query to create a `books` table with specific columns.
order: 300
type: challenge
initSteps: []
expectedResults:
- columns: [message]
values:
- ['Table created successfully']
---
You are required to create a table named `books` for a bookstore database. The table should have the following columns:
| Column Name | Data Type | Constraints |
| -------------- | -------------- | ----------------- |
| id | INTEGER | PRIMARY KEY |
| title | VARCHAR(250) | NOT NULL |
| author | VARCHAR(250) | NOT NULL |
| genre | VARCHAR(250) | |
| price | DECIMAL(10, 2) | CHECK (price > 0) |
| published_date | DATE | |
Table should have following constraints in place:
- The `id` column should uniquely identify each book.
- The `title` and `author` columns cannot be `NULL`.
- The `price` column must be greater than `0`.
## Expected Output
After executing the query, there should be no errors and the table should be created successfully.

@ -59,6 +59,14 @@ p > code:before,
.prose ol li > code:before, .prose ol li > code:before,
p > code:before, p > code:before,
.prose ol li > code:after, .prose ol li > code:after,
.course-content h1 > code:after,
.course-content h1 > code:before,
.course-content h2 > code:after,
.course-content h2 > code:before,
.course-content h3 > code:after,
.course-content h3 > code:before,
.course-content h4 > code:after,
.course-content h4 > code:before,
p > code:after, p > code:after,
a > code:after, a > code:after,
a > code:before { a > code:before {
@ -73,13 +81,16 @@ a > code:before {
.course-content em > code, .course-content em > code,
.course-content h1 > code, .course-content h1 > code,
.course-content h2 > code, .course-content h2 > code,
.course-content h3 > code { .course-content h3 > code,
.course-content table code {
background: #f4f4f5 !important; background: #f4f4f5 !important;
border: 1px solid #282a36 !important; border: 1px solid #282a36 !important;
color: #282a36 !important; color: #282a36 !important;
padding: 2px 4px; padding: 2px 4px;
border-radius: 5px; border-radius: 5px;
font-size: 17px !important; font-size: 16px !important;
white-space: pre;
font-weight: normal;
} }
.course-content.prose blockquote h1, .course-content.prose blockquote h1,

Loading…
Cancel
Save