parent
7f60f1301e
commit
8369f01d99
6 changed files with 112 additions and 35 deletions
@ -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. |
@ -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. |
Loading…
Reference in new issue