-
Notifications
You must be signed in to change notification settings - Fork 3
Ilias_Khugaev-w1-Databases #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Ilias_Khugaev-w1-Databases #5
Conversation
yunchen4
left a comment
There was a problem hiding this 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. 🙂
Week1/databases/assigment/meetup.js
Outdated
| 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))'); |
There was a problem hiding this comment.
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.
Week1/databases/assigment/meetup.js
Outdated
| 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)'); |
There was a problem hiding this comment.
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).
| 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")'); |
There was a problem hiding this comment.
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.
Week1/databases/assigment/world.js
Outdated
| // What's the top 10 countries by Surface Area? | ||
| await connection.query('SELECT name FROM country ORDER BY SurfaceArea LIMIT DESC 10'); |
There was a problem hiding this comment.
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.
|
@yunchen4 Hi, thank you for your work. Here are my fixes! |
yunchen4
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No description provided.