Skip to content

Conversation

@Narpimers
Copy link

No description provided.

@yunchen4 yunchen4 self-assigned this May 24, 2025
Copy link

@yunchen4 yunchen4 left a comment

Choose a reason for hiding this comment

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

Hi Ilias,

I am Chen and will review your assignments for the database module.
The assignment for week 1 has one point that needs rework. I have made it explicit. Otherwise it looks good. I also left some suggestions that can improve your query.

Please ping me on Slack when you finish the rework, or when you have any questions about database. 🙂

try {
await connection.query('CREATE DATABASE IF NOT EXISTS meetup');
await connection.query('USE meetup');
await connection.query('CREATE TABLE Invitee (invitee_no INT NOT NULL PRIMARY KEY, invitee_name VARCHAR(25) NOT NULL, invited_by VARCHAR(25))');

Choose a reason for hiding this comment

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

suggestion: when you define a column as PRIMARY KEY you don't need to add NOT NULL restriction, as the primary key needs to be not null.

And you can also add AUTO_INCREMENT for invitee_no, as it is a int. This way you won't need to specify invitee_no when you insert new rows into the table.

await connection.query('CREATE DATABASE IF NOT EXISTS meetup');
await connection.query('USE meetup');
await connection.query('CREATE TABLE Invitee (invitee_no INT NOT NULL PRIMARY KEY, invitee_name VARCHAR(25) NOT NULL, invited_by VARCHAR(25))');
await connection.query('CREATE TABLE Room (room_no INT NOT NULL PRIMARY KEY, room_name VARCHAR(25) NOT NULL, floor_number INT NOT NULL)');

Choose a reason for hiding this comment

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

suggestion: Usually floor number is not a big number. If you want to decrease the size of your table, you can use tinyint for floor_number.

tinyint only takes 1 byte and int will take 4 bytes to store (doc).

Comment on lines +19 to +23
await connection.query('INSERT INTO Invitee VALUES (1, "Ilias Khugaev", "Ilia Bubnov")');
await connection.query('INSERT INTO Invitee VALUES (2, "Anna Petrova", "Ilias Khugaev")');
await connection.query('INSERT INTO Invitee VALUES (3, "Dmitry Sokolov", "Anna Petrova")');
await connection.query('INSERT INTO Invitee VALUES (4, "Maria Ivanova", "Dmitry Sokolov")');
await connection.query('INSERT INTO Invitee VALUES (5, "Oleg Smirnov", "Maria Ivanova")');

Choose a reason for hiding this comment

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

If you add AUTO_INCREMENT for invitee_no then you don't need to specify 1,2,3,4,5 when inserting new invitees.

Comment on lines 28 to 29
// What's the top 10 countries by Surface Area?
await connection.query('SELECT name FROM country ORDER BY SurfaceArea LIMIT DESC 10');

Choose a reason for hiding this comment

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

Need rework: This query (for top 10 countries by surface area) has syntax error. Please check it again.

@Narpimers
Copy link
Author

@yunchen4 Hi, thank you for your work. Here are my fixes!

Copy link

@yunchen4 yunchen4 left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants