Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A problem that may ORMs have is thinking/working with row-expressions rather than sets. If everything is expressed in plural sometimes with zero or one, other times many, then the N+1s mostly go away. The same goes for many interfaces/APIs that have single and multiple forms, only make the multiple forms and have callers call it with [single].

Related pet peeve: calling tables by plural names. The table (or any relation) should be named for the set of X rather than thinking of it as Xs.



> A problem that may ORMs have is thinking/working with row-expressions rather than sets.

Absolutely. There's a reason that the famous Out Of The Tar Pit[1] paper identifies relational algebra as the solution to many programming woes. Thinking in sets instead of individual items is extremely powerful, when using an ORM and also in general. If an ORM makes this hard, use a different one (hopefully there is a better option).

> Related pet peeve: calling tables by plural names

Agreed again! Based on my limited observations, this seems like a big cultural difference between "database people" and "software people". The people who spend most of their time working directly in databases (and trying to basically write fully fledged business applications entirely in the database layer) seem to think of tables as big containers. If you labeled a box full of people (or a binder full of women?), you'd probably label it "People". Whereas "software people" tend to think of a database table as a definition of something, more like a class or type. Clearly the correct label for that definition is "Person".

Actually the latter is also wrong for a different reason: that is not how nouns work. But that's a story too long to fit in this comment.

[1] Out of the tar pit (warning: direct link to 66-page PDF): https://curtclifton.net/papers/MoseleyMarks06a.pdf


It's the other way around - "software people" tend to use plurals for table names, because it then maps nicely to plurals in property names in their object layer, where it's already the established convention.

The "database people" OTOH tend to use singular, which goes at least as far back as C.J. Date. I'm not sure why, but perhaps it's because fully qualified field names read more natural.


Actually, all the old relational texts talk about select * from employees (plural) because they didn’t have aliases for table names in queries.

I agree that when you use aliases for multiple tables when you use (Oracle, non-standard SQL joins) that it looks prettier, but you can also do that with plural table names.

Select employee.name manager.name from employee, manager where employee.manager_id = manager.id

But it doesn’t matter that much when you use the traditional join syntax:

Select employees.name, managers.name from employees left outer join managers as manager on employees.manager_id = managers.id

Still I prefer singular table names, just disagree that it was data people who preferred singular and why.

Of course, with aliases you can return the exact name you want with aliases:

Select e.name as employee, m.name as manager from employees e, managers m where e.manager_id = m.id


it is either a bunch of apples in which case you would call it apples, or it is the box that holds apples, in which case you would call it apple. as in apple_box.

Got to admit I am pretty firmly in "it is the box that holds apples" camp so none of my array, table, dictionary names are plural. Some time I comfort myself by saying "well, apple[5] just sounds better" but that is really up for debate.


But a set is plural. We say "the set of things", not "the set of thing".


I guess it depends on usage that's familiar to you. I would say set of Real numbers and call the set Real (like a class) not Reals like a collection of instances.


I agree with your pet peeve. ActiveRecord (Rails ORM) encourages by convention that your tables are named in the plural, and it sometimes drives me crazy. When writing queries outside the ORM, I end up aliasing tables/relations to the singular so the query is more sane to reason about, e.g.:

> SELECT person.id, person.name, person.age ... FROM people person JOIN ...

Which reads so much nicer to me than:

> SELECT people.id, people.name, people.age ... FROM people JOIN ...

(obviously a somewhat contrived example because of the people/person inflection that makes it awkward already)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: