Milestone 5: Transforming the generated UML diagram to a database for the property management system.

Milestone 5: Transforming the generated UML diagram to a database for the property management system.

In my previous milestone 4, I describe the reasons why I chose Ruby on Rails for my backend and React for my front end. Now, I'm excited to delve into the next step of this journey. In this article, I will be transforming the UML diagram, crafted in milestone 3, into a fully functional database using the power of Ruby on Rails.

Creating the Database

  • I started by creating a repository in GitHub and cloning it to my local computer using a version control called git

  • I Install Ruby on Rails in the project using the command rails new . --api --database=postgresql. I will be working with API and using the Postgres database. Furthermore, I set up linters that help to check my codes to see if I'm following the best code practices

  • I ran bundle install to install all the default dependencies

  • I started creating the tables using the following commands

      Rails g scaffold user name email password occupation phone_number:integer
      Rails g scaffold category name 
      Rails g scaffold security gate:boolean securityMan:boolean  
      Rails g scaffold location city quater:text longitude:decimal latitude:decimal
      Rails g scaffold place name 
      Rails g scaffold house title number_of_houses:integer price:decimal metal_type:string water_source funitures:boolean user:references category:references security:references location:references 
      Rails g scaffold nearByPlace name distance:decimal place:references house:references
      Rails g scaffold comment description user:references house:references
    
  • If you check the house table, you will see I omitted the video and image attributes. This is because I will use active storage to store them. For more information about active storage, I wrote an article explaining it and how it works here is the link.

  • Lastly, I created the database by running this command rails db:create db:migrate. This command creates the database in Postgres and generates all the tables as shown below.

To conclude, I successfully completed this milestone of transforming the UML diagram into a functional database. In my next milestone, I will create the API endpoints for user and house tables stay tuned!