diff --git a/src/data/courses/sql/chapters/data-definition-language/lessons/challenge-1.md b/src/data/courses/sql/chapters/data-definition-language/lessons/challenge-1.md deleted file mode 100644 index 53f5ca228..000000000 --- a/src/data/courses/sql/chapters/data-definition-language/lessons/challenge-1.md +++ /dev/null @@ -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! diff --git a/src/data/courses/sql/chapters/data-definition-language/lessons/table-creation.md b/src/data/courses/sql/chapters/data-definition-language/lessons/table-creation.md new file mode 100644 index 000000000..fa46103e4 --- /dev/null +++ b/src/data/courses/sql/chapters/data-definition-language/lessons/table-creation.md @@ -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. diff --git a/src/data/courses/sql/chapters/sql-basics/lessons/expression-projection.md b/src/data/courses/sql/chapters/sql-basics/lessons/select-expression.md similarity index 98% rename from src/data/courses/sql/chapters/sql-basics/lessons/expression-projection.md rename to src/data/courses/sql/chapters/sql-basics/lessons/select-expression.md index 56c56dd5b..536b8aa76 100644 --- a/src/data/courses/sql/chapters/sql-basics/lessons/expression-projection.md +++ b/src/data/courses/sql/chapters/sql-basics/lessons/select-expression.md @@ -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. order: 310 type: challenge diff --git a/src/data/courses/sql/chapters/sql-basics/lessons/unique-projection.md b/src/data/courses/sql/chapters/sql-basics/lessons/select-unique.md similarity index 98% rename from src/data/courses/sql/chapters/sql-basics/lessons/unique-projection.md rename to src/data/courses/sql/chapters/sql-basics/lessons/select-unique.md index 1228e9ba9..1fe894865 100644 --- a/src/data/courses/sql/chapters/sql-basics/lessons/unique-projection.md +++ b/src/data/courses/sql/chapters/sql-basics/lessons/select-unique.md @@ -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. order: 330 type: challenge