Skip to content

Diana C.#1

Open
dianadenwik wants to merge 1 commit into
HackYourAssignment:mainfrom
dianadenwik:main
Open

Diana C.#1
dianadenwik wants to merge 1 commit into
HackYourAssignment:mainfrom
dianadenwik:main

Conversation

@dianadenwik
Copy link
Copy Markdown

…with better-sqlite3

@github-actions
Copy link
Copy Markdown

📝 HackYourFuture auto grade

Assignment Score: 0 / 100 ✅

Status: ✅ Passed
Minimum score to pass: 0
🧪 The auto grade is experimental and still being improved

Test Details

Copy link
Copy Markdown

@rafasilpereira rafasilpereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! 👏 👏

Both tasks were succesfully implemented with a clear and solid code!

Comment thread task-1/queries.sql

--Question 6** — Add one book for the author you just inserted. It can be a real book or a made-up one.
INSERT INTO books (title, published_year, genre, author_id)
VALUES ('Spaces',2005, 'Fantasy', 25);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! A challenge: there is a way of doing a SELECT to find the author_id. How would you do that? Tip: I can add doing something like ...VALUES('Rafael', 'Pereira', (SELECT id FROM customers)) ;)

Comment thread task-1/queries.sql
--Question 7** — The genre for "The Dark Tower: The Gunslinger" was entered incorrectly as `'Fantasy'`. It should be `'Horror'`. Write an UPDATE to fix it, then verify the change with a SELECT.
UPDATE books
SET genre = 'Horror'
WHERE title = 'The Dark Tower: The Gunslinger';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one here! Adding exactly the title for UPDATE or DELETE and avoiding using LIKE makes you changing one what is needed, without the risk of updating or deleting not wanted rows

Comment thread task-1/queries.sql

--Question 8** — Delete the book you added in Question 6. Make sure your query targets only that specific row.
DELETE FROM books
WHERE books.id = 101;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would write this if you don't know the id to be deleted? Just a thing to consider if you have a database with many rows ;)

Comment thread task-1/queries.sql

-- **Bonus B** — Find any authors in the database who have no books at all. _(Hint: you will need a LEFT JOIN and check for NULL.)
--**Bonus A** — How many books are there per genre? Show the genre name and the count, ordered from most to fewest books.
SELECT genre, COUNT(*) AS book_count
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done in using an ALIAS! Makes more clear and logic to use in code later!

Comment thread task-2/migrate.js

// Open the database file.
// If the file doesn't exist, better-sqlite3 will create it.
const db = new Database("data/flashcards.db");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very solid and direct implementation of the migration! 👏

@rafasilpereira rafasilpereira added Reviewed This assignment has been reivewed by a mentor and a feedback has been provided and removed Review in progress labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants