parent
d20c253e2b
commit
7f60f1301e
4 changed files with 34 additions and 57 deletions
@ -1,55 +0,0 @@ |
|||||||
--- |
|
||||||
title: Challenge 1 |
|
||||||
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 tasked with creating 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 | TEXT | NOT NULL | |
|
||||||
| author | TEXT | NOT NULL | |
|
||||||
| genre | TEXT | | |
|
||||||
| price | NUMERIC(10, 2) | CHECK (price > 0) | |
|
||||||
| published_date | DATE | | |
|
||||||
|
|
||||||
### Requirements |
|
||||||
|
|
||||||
1. The `id` column should uniquely identify each book. |
|
||||||
2. The `title` and `author` columns cannot be null. |
|
||||||
3. The `price` column must be greater than 0. |
|
||||||
|
|
||||||
### Task |
|
||||||
|
|
||||||
Write a SQL query to create the `books` table as described above. |
|
||||||
|
|
||||||
### Expected Output |
|
||||||
|
|
||||||
After running your query, the output should confirm the creation of the table: |
|
||||||
|
|
||||||
| message | |
|
||||||
| -------------------------- | |
|
||||||
| Table created successfully | |
|
||||||
|
|
||||||
### Example Query (Partial) |
|
||||||
|
|
||||||
```sql |
|
||||||
CREATE TABLE books ( |
|
||||||
id INTEGER PRIMARY KEY, |
|
||||||
title TEXT NOT NULL, |
|
||||||
author TEXT NOT NULL, |
|
||||||
genre TEXT, |
|
||||||
price NUMERIC(10, 2) CHECK (price > 0), |
|
||||||
published_date DATE |
|
||||||
); |
|
||||||
``` |
|
||||||
|
|
||||||
Now, complete the challenge and create the table! |
|
@ -0,0 +1,32 @@ |
|||||||
|
--- |
||||||
|
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. |
@ -1,5 +1,5 @@ |
|||||||
--- |
--- |
||||||
title: Expression Projection |
title: Select Expression |
||||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||||
order: 310 |
order: 310 |
||||||
type: challenge |
type: challenge |
@ -1,5 +1,5 @@ |
|||||||
--- |
--- |
||||||
title: Unique Projection |
title: Select Unique |
||||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||||
order: 330 |
order: 330 |
||||||
type: challenge |
type: challenge |
Loading…
Reference in new issue