Skip to content

Conversation

@Alaa2019-ml
Copy link

No description provided.

@crevulus crevulus self-assigned this Nov 28, 2025
@crevulus
Copy link

crevulus commented Dec 1, 2025

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.

@Alaa2019-ml
Copy link
Author

Database.js
CreateTables.js
Select queries.js

Intended to follow a similar naming of the files in the scripts folder.
I am sorry for confusing

@Alaa2019-ml
Copy link
Author

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

Copy link

@crevulus crevulus left a 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.

port: 5432,
user: "hyfuser",
password: "hyfpassword",
database: "prep-ex2",
Copy link

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.

await client.connect();
console.log("Connected to PostgreSQL database!");

await client.query(
Copy link

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?

date_of_birth DATE,
h_index INTEGER,
gender VARCHAR(1) CHECK (gender IN ('m', 'f')),
mentor INTEGER
Copy link

Choose a reason for hiding this comment

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

check the MAKEME requirements:

  1. Create a table, called authors. Give it the following fields: (author_id(Primary Key), author_name, university, date_of_birth h_index, gender)
  2. Write a query that adds a column called mentor to authors table that references the column author_id.

You should not create the table with a mentor column; add it later.

await query4();
await query5();
await query6();
await query7();
Copy link

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) {
Copy link

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?

@Alaa2019-ml
Copy link
Author

I have updated the files based on your feedback. I hope they are correct now.
Thank you.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants