A dockerized database!

1) Checkout the main branch of our project and copy the 'docker-compose.yml' file to your project in the root folder.

Once you copy it, IntelliJ will prompt you to install the Docker plugin, feel free to try it!


2) Docker compose UP!

Use your command line, in the same folder where you have docker-compose.yml, type: 'docker compose up' and see what happens! Explore Docker Desktop to see what changed. Check 'Containers, Images and Volumes! What do they mean?


3) Take a deep breath!

If everything went well so far, it means you now have a running database accessible in your computer, congrats! Analyze the docker-compose.yml file... what are those strange lines doing? Try to understand it.


4) Alrighty! Let's connect to our first database!

1. Open DBeaver. 2. Exclude DBeaver from your computer scans. 3. Don't create a sample databse. 4. Guess what? We are using Postgres! Pick it up when the "Select your database" pop up appears! 5. Change 'Database' to 'ecologika' 6. Change 'Username' to 'user' 7. Change 'Password' to 'password' (super safe right?!) 8. Notice that these configurations were defined in the docker-compose file! 9. Click the 'Test Connection' button. 10. Download 'org.postgresql:postgresql:RELEASE driver but click on the version and choose 42.7.5 11. Then a pop up with the successful connection should appear! Click ok! 12. If you expand on your left the newly created connection you can now see at 'Databases' your new db!


4) SQL... Our first table!

In session 07 assignments we created some scripts to create tables... Press F3 in DBeaver to open up a script window, paste them and run them with Ctrl+Enter!


5) Our first entities!

Create your first Product and Company in the database the same way you created the tables!


6) We need to map these to our spring boot application....!

Find out what Java Persistence API is (JPA) and try to apply it... Can you create companies with our REST API into our database? Can you fetch them as well? hint: this is hard. good luck champ!