DEV Community

kealanheena
kealanheena

Posted on

Makers Week 4: Databased on a True Story

We started on using databases this week. We are using a SQL database called postgres. It's all new but also it's nice to be able to store data. Although it is a lot to learn in a week hopefully I'll manage.

Day 1

We started on databases and learning how to use them. It was a slow start trying to wrap our heads around them. The challenge was to build a bookmark app that stored URLs. We had to set up the database first which wasn't hard because the documentation was clear. The main issue is how to write the tests for the database which used capybara which I'm not too confident about but we were able to get it started.

Day 2

The next day we learned how to interact with postgres within ruby which was similar to normal postgres. All you needed to do was use the exec command before using the same code you'd use in postgres. It was interesting to see the databases in use and how we could alter them to add info to the website.

Day 3

We were shown a new tool to use called TablePlus which seemed to be more of a visual interface for sql databases. It was definitely nicer to look at than the terminals psql so I could see it being useful. After seeing that wee had to set up a testing environment. We needed to set up a test database so we don't mess up the database for the active site. We also had to reset our database every time so we used TRUNCATE to clear the database.

Day 4

Step 10 took quite long because it was creating a full-stack feature. We had to give the user the ability to create bookmarks. So, first of all, we had to create a form that would take the users URL. Then we had to pass it through the post route. Finally, we had to add the user's input to the database so it could then be displayed on the page.

Day 5

We spent this day refactoring our code. We had to take our data out of an array and change it to a hash. This makes it both more readable and more usable. This took longer than expected because be we had to change our test too to use hashes instead of arrays.

Summary

I really enjoyed this week mainly because we got to build apps that actually run. It was quite irritating since I had to use walkthroughs a lot. even though we were told we'd probably have to use them it would’ve been nice to have been able to figure it out by myself.

Oldest comments (0)