Skip to content

Mareh A. - #19

Open
mareh-aboghanem wants to merge 1 commit into
HackYourAssignment:mainfrom
mareh-aboghanem:main
Open

mareh-aboghanem wants to merge 1 commit into
HackYourAssignment:mainfrom
mareh-aboghanem:main

Conversation

@mareh-aboghanem

Copy link
Copy Markdown

No description provided.

@github-actions

github-actions Bot commented Apr 1, 2026

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

@rafasilpereira rafasilpereira left a comment

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 job!

Your implementations in task 2 were good and worked as expected!

I would review the queries for task 1 making sure that the results that you are getting is the expected.

Comment thread task-1/queries.sql

-- **Question 1** — List the title and published year of every book in the `'Science Fiction'` genre, ordered by published year (oldest first).
SELECT title , published_year FROM books
WHERE books.genre = 'Science Fiction';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is query is not ordering by published year with oldest first. How would you change it?

Comment thread task-1/queries.sql
-- **Question 3** — Show every book in the database along with its author's full name. Combine `first_name` and `last_name` into a single column called `author`. _(Hint: you will need a JOIN.)_

SELECT title , published_year , authors.first_name || ' ' || authors.last_name AS author FROM books
JOIN authors ON author_id = books.author_id;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When I run this query, these are the results that are I receive below with duplicate results. The problem is in the JOIN and the id used for checking. How would you fix it?

Harry Potter and the Philosopher's Stone 1997 J.K. Rowling
Harry Potter and the Philosopher's Stone 1997 George R.R. Martin
Harry Potter and the Philosopher's Stone 1997 J.R.R. Tolkien
Harry Potter and the Philosopher's Stone 1997 Agatha Christie
Harry Potter and the Philosopher's Stone 1997 Stephen King

Comment thread task-1/queries.sql
-- **Question 4** — List all books written by Stephen King. Show the title and published year, ordered by year. _(Hint: JOIN the two tables and filter on the author's name.)_

SELECT title , published_year FROM books
JOIN authors ON author_id = books.author_id

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This query doesn't return results. The problem is with the choose of the id to compare

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("HI",2026,"Horror",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

-- These cover topics slightly beyond the core material. Have a go if you finish early.

-- **Bonus A** — How many books are there per genre? Show the genre name and the count, ordered from most to fewest books.

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 doing the bonus!

Comment thread task-2/src/database.js
// TODO: set learned = 1 for the card with the given id
// return the updated row, or null if not found
throw new Error('Not implemented');
const stmt = 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.

The const stmt is not used in any other place and you are storing in memory. How would you run the UPDATE without creating a const?

Comment thread task-2/src/database.js
const stmt = db.prepare("SELECT * FROM decks");
const rows = stmt.all();
return rows;
//throw new Error('Not implemented');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you have the same comment many times, maybe better to remove them all? ;)

@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.

2 participants