Skip to content
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

Feature3/query mulitple tables #10

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

OmarRamoun
Copy link
Owner

Changes Introduced ♻️

✔️ Create a table named owners with the following columns:

attribute value
id integer (set it as autoincremented PRIMARY KEY)
full_name string
age integer

✔️ Create a table named species with the following columns:

attribute value
id integer (set it as autoincremented PRIMARY KEY)
name string

✔️ Modify animals table:

  • Make sure that id is set as autoincremented PRIMARY KEY
  • Remove column species
  • Add column species_id which is a foreign key referencing species table
  • Add column owner_id which is a foreign key referencing the owners table

✔️ Insert the following data into the owners table:

 owner_id |    full_name    | age
----------+-----------------+-----
        1 | Sam Smith       |  34
        2 | Jennifer Orwell |  19
        3 | Bob             |  45
        4 | Melody Pond     |  77
        5 | Dean Winchester |  14
        6 | Jodie Whittaker |  38

✔️ Insert the following data into the species table:

 species_id |  name
------------+---------
          1 | Pokemon
          2 | Digimon

✔️ Modify your inserted animals to include owner information (owner_id):

  • Sam Smith owns Agumon.
  • Jennifer Orwell owns Gabumon and Pikachu.
  • Bob owns Devimon and Plantmon.
  • Melody Pond owns Charmander, Squirtle, and Blossom.
  • Dean Winchester owns Angemon and Boarmon.

✔️ Write queries (using JOIN) to answer the following questions:

  • What animals belong to Melody Pond?
  • List of all animals that are pokemon (their type is Pokemon).
  • List all owners and their animals, remember to include those that don't own any animal.
  • How many animals are there per species?
  • List all Digimon owned by Jennifer Orwell.
  • List all animals owned by Dean Winchester that haven't tried to escape.
  • Who owns the most animals?

@OmarRamoun OmarRamoun added the enhancement New feature or request label Jun 19, 2022
@OmarRamoun OmarRamoun self-assigned this Jun 19, 2022
Copy link

@mateo951 mateo951 left a comment

Choose a reason for hiding this comment

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

Hi @OmarRamoun,

Your project is complete! There is nothing else to say other than... it's time to merge it 🙌

Congratulations! 🎉

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

Comment on lines +25 to +29
CREATE TABLE owners (
owner_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY NOT NULL,
full_name VARCHAR(255) NOT NULL,
age INT NOT NULL
);

Choose a reason for hiding this comment

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

Well done 🙌 You added a new table with the name owners and the propper columns 💪

- name: string
*/

CREATE TABLE species (

Choose a reason for hiding this comment

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

Again, splendid work 🙌 You added a new table species and the propper columns ✔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants