-
Notifications
You must be signed in to change notification settings - Fork 9
Alaa_Nasher-w2-databases #19
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?
Alaa_Nasher-w2-databases #19
Conversation
|
Hi @Alaa2019-ml, I'm unclear in which order I should run your files in order to test your assignments. Could you please tell me which files I should run and in which order? I can try to guess, but I don't want to unfairly review your code based on my misinterpretation of the correct files/order. One of the things that is confusing is that there are two different database configurations. There should only be one. For future reference, it's best to name your files based on the number/name of the exercises in the MAKEME file, e.g. name them something like exercise1.js or 1_keys.js. |
|
Database.js Intended to follow a similar naming of the files in the scripts folder. |
|
The database.js is to create the database and the configuration in the createTables.js is to connect to the database I created in database.js |
crevulus
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 Alaa,
Good job this week. The data you've chosen to poulate the tables is great for demonstrating the power of SQL.
There's a couple of comments I've left that are important to fully passing the assignment requirements. Please fix them and the other comments when you can.
Week2/assignment-w2/createTables.js
Outdated
| port: 5432, | ||
| user: "hyfuser", | ||
| password: "hyfpassword", | ||
| database: "prep-ex2", |
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.
You created the dbName variable in another file - you should use it here to ensure consistency.
Week2/assignment-w2/createTables.js
Outdated
| await client.connect(); | ||
| console.log("Connected to PostgreSQL database!"); | ||
|
|
||
| await client.query( |
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.
You can't TRUNCATE a table before it exists - you try to TRUNCATE here but only create the table on line 78.
Did you mean to DROP the table instead?
Week2/assignment-w2/createTables.js
Outdated
| date_of_birth DATE, | ||
| h_index INTEGER, | ||
| gender VARCHAR(1) CHECK (gender IN ('m', 'f')), | ||
| mentor INTEGER |
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.
check the MAKEME requirements:
- Create a table, called
authors. Give it the following fields:(author_id(Primary Key), author_name, university, date_of_birth h_index, gender)- Write a query that adds a column called
mentortoauthorstable that references the columnauthor_id.
You should not create the table with a mentor column; add it later.
Week2/assignment-w2/selectQueries.js
Outdated
| await query4(); | ||
| await query5(); | ||
| await query6(); | ||
| await query7(); |
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.
Instead of writing out each query invocation, is there a way you could iterate through a list of queries and call them one after the other?
| await client.query(CREATE_RESEARCH_AUTHORS); | ||
| console.log("Research Authors table created successfully"); | ||
|
|
||
| for (const author of authors) { |
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.
You loop through authors to insert data twice. Could you do it just once?
|
I have updated the files based on your feedback. I hope they are correct now. |
No description provided.