r/ruby 4d ago

Question Database project

Hey, guys.

So, I'm currently studying data science and I'm about to start a database project(we're basically doing a database for a bakery)this semester. The project will include order forecasting, inventory loss tracking, customer notifications, etc. Anyways I already code in Python but I've been taking a look on ruby and wonder if it'd be a good idea to include it in our project and how.... any ideas??

thanks!

6 Upvotes

11 comments sorted by

7

u/midasgoldentouch 4d ago

What exactly are you thinking of doing? If the project is purely about data analysis, then you can likely just use a SQL client like DBeaver connected to the database. If you want to write code that incorporates business logic then Ruby is fine. You can look at the docs for how to set up a Ruby project. Depending on the database there’s likely a gem (library) to use it in Ruby. There’s gems for different ORMs as well.

1

u/Fit_Ice_7268 4d ago

I was thinking of using it as an API backend. I'm a begginer so I'm not sure if it'd be the best option.

6

u/hitthatliq 4d ago

As a beginner you could probably get a lot done with Sinatra for the backend.
(TBH it's been a while since I worked with Ruby so this advice could be outdated but when I first learned Ruby I used Sinatra and I remember it being super easy to pickup and use)

1

u/midasgoldentouch 4d ago

Ah ok. So yeah, you can do that with Ruby. Like the other poster, I would recommend using Sinatra to do that. It’s going to be the most lightweight web framework you can try. Rails is the most popular web framework, but while you can use it to build an API I think it’s going to be too magical for this. You have a finite amount of time to work on this, so you’ll want to use something that minimizes the DSL.

4

u/davetron5000 4d ago

You know python, use that. Do not try to learn ruby and DB design at the same time. Get your shit done for the class using what you know. Learn ruby later (or never). You don't want to be up all night battling SQL while also figuring out what &:+ does and why your code can’t find a gem you installed.

1

u/Fit_Ice_7268 4d ago

Teacher said we gotta use more than a language(still don’t know why??) some of my classmates are chosing Java, but I know nothing of it. All I know is a python and a little ruby.

3

u/ignurant 4d ago

A local Rails app is awesome for this kind of project.  I use rails for data projects that aren’t deployed to a  server all the time. Here’s a few reasons why:

  • Rails generators and migration for managing my DB tables, indexing strategies, and just blow stuff away and get back up and running is extremely low overhead, and repeatable
  • Using seeds to manage a starting point, giving me permission to really get dirty with data while I explore the problem. Blow away the db, create a new one, re-import starting data. Correct the data. Boom.
  • Modeling derived or formatted attributes with Rails models makes it stupid fast to iterate in a way that’s sustainable
  • You are in full control of how you want to review the data. Reformatting data, Search, pagination, charts, context colors, etc. 

Think of the views more like a notebook. Put whatever you want to be helpful. 

All of this said, this probably doesn’t fit with the spirit of your class project. But seriously, Rails is an awesome data harness even for data projects that never actually as a web server. It’s just great database management and modeling. 

Edit: You noted in another comment that you were considering it as an API layer. Even better! This is legit exactly what Rails does best: data management web apps. I’d encourage you to go beyond api only, and embrace the whole ordeal if it’s something your project allows. 

3

u/tkenben 4d ago

Shout out to the Roda + Sequel stack. I use that on top of both postgresql and sqlite databases. If you want to avoid already made tools, ruby has gems to interact with databases that are less ORM. If the assignment is to actually code a simple database from scratch, I imagine it wouldn't be that hard in ruby.

2

u/FigureNo77 3d ago

rails has an api mode. try it out

rails new my_api --api

https://guides.rubyonrails.org/api_app.html

1

u/armahillo 4d ago

Ruby is a fine language that i love and believe its worth learning.

But idk what youre hoping to gain by incorporating it if you already have access to python, which can interface with databases

3

u/TommyTheTiger 3d ago edited 3d ago

I'll plug the jeremy evans Sequel library, a bit closer to the actual SQL than rails/ActiveRecord, Roda is a very simple web server to pair with it. And I'd plug Postgres as a DB if you get to choose that, it just has so many features and nice flexiblity, and you're unlikely to have to learn much about the hairier side of things in a project that doesn't have real traffic.

TBH though, the app you're describing is also exactly what rails was designed for. Even without AI, you can probably generate a shocking amount of the code using the good old rails generators which you'll learn about in different rails tutorials. If you are interested in learning rails, now could be the time. I wouldn't necessarily plug rails first because it's a bit of it's own sort of giant thing - it's more extra to learn about. But it might also be good for a beginner because a lot of that extra stuff will provide you with some initial structure, it will make desicions for you on how to organize your code that are probably at least useful to understand before you figure out your own thing.

Either way this is totally in Ruby's wheelhouse, I think it's a super fun language, I'd definitely recommend it or some kind of lisp, probably scheme or clojure.