Is it possible to avoid plurals altogether in the db and all schemas

I am using a lot of generators so I am worried that if I try to go it alone and singularize all references to everything that I’ll break something somewhere in the code; but I really don’t understand the value in pluralizing or not pluralizing names for things. Do they need to read like sentences?

I can draw plenty of understanding from something called the user table, there’s no way that I will get lost and think that I have lost all my users because it isn’t indicating that there are a lot of them.

The main problem that I have is figuring out which form to use when I am referencing the various things like the schema, the db, filenames, etc; and like I said it doesn’t seem to offer that much in return for this frustration except potential pitfalls.

Is there some deeper meaning to it that I am not yet experienced enough to see? Would there be actual conflicts down the road if I singularize everything in the generators?

There will be no problems singularizing everything. If that’s your preference go for it! :slight_smile:

2 Likes

The plurals are just a convention when generating stuff. You can just as easily have an Elixir data model that points to a completely bonkers table name.

To follow on from @dimitaRV 's comment, it’s just convention, which to hazard a guess, I’d have to say it originates from the use of a for loop to iterate a collection, like in most languages, e.g

for thing in things
	do work on thing
end for

So, in the above loop, using such convention you can use singular and plural when iterating, plural is obviously a collection of some type whilst when using singular it becomes obvious that you are working / operating on a single instance.

The intrinsic benefit of such a convention is that the code speaks for itself, I.e there’s no need for comments, it’s self documenting.

1 Like

Thank you everyone, I am glad to hear that I can singularize everything. I had the same problem in Ruby on Rails and understand why it could be useful; but it just isn’t useful enough for me to want to think about it!

If I remember right Rails didn’t even give the option, it insisted and did magic behind the scenes to force you to have to pluralize. I’ve left those bad memories behind now. :slight_smile:

2 Likes

Rails (or active record rather; I used it with Sinatra back in the day) did give you the option, but it was a terrible chore to figure out how to do it, which is effectively, “no option”. I remember consternating “but how would rails know if I wanted to pluralize Fish to Fishes or Fish”. Anyways, that magic was awful. And I’m glad Elixir is much more explicit about these things.