Topic: Modeling a Research App

Hi all

Re: Modeling a Research App

czheng wrote:

First and foremost, is there a better way to do this that I

Railscasts - Free Ruby on Rails Screencasts

Re: Modeling a Research App

thanks very much... i'll try it as you suggest. i'm glad to hear i was somewhat on the right track. but if anyone else has thoughts, i'd love to hear them. thanks.

Re: Modeling a Research App

Woke up this morning wondering whether it would be possible (or desirable) to do it like this (and I'm following this page from the wiki here):
  * AUTHORS has_many ATTRIBUTIONS (or something like that)
  * ATTRIBUTIONS belongs_to AUTHOR and belongs_to ATTRIBUTABLE (polymorphic)
  * WORKS has_many ATTRIBUTIONS as ATTRIBUTABLE, and has_many AUTHORS through ATTRIBUTIONS
  * QUOTES has_many ATTRIBUTIONS as ATTRIBUTABLE, and has_many AUTHORS through ATTRIBUTIONS
  * this is the part that isn't on that wiki page, and which I'd like to know if it will work: QUOTES still belongs_to WORKS and WORKS still has_many quotes.

This makes me nervous because, first, I would have three polymorphic associations going (remember NOTES and COMMENTS), and I'm not sure whether that's ok. Second, because there's a sense of overlap here, in how I'm associating AUTHORS, WORKS and QUOTES. Again, ideally QUOTES and AUTHORS would join through WORKS, but WORKS and AUTHORS need to be many to many... So, is this possible and if so, is it better than the above?

Re: Modeling a Research App

Your database design isn't quite normalized.

You are right that Authors should be its own table, as would Publishers. There are many authors and publishers who have more than one Work. By having them in their own table and having Works point to them you prevent entering duplicate info. This also solves the multiple Authors issue.

Will your works and quotes tables each have enough information to automatically build a proper citation that can then be copy/pasted into your bibliography? Better yet, generate properly formatted LaTeX/BibTex code*?

Your idea is great, I wish I had it when I was in college to manage my notes. The post-it is dead, long love the czheng System!

*-If you're writing a lot of papers or presentations and haven't looked at LaTeX, try it. It is a HUGE time saver especially if you're already comfortable typing code instead of full text. There is a bit of a learning curve, but it is well worth it.

Re: Modeling a Research App

Thanks for the input and encouragement.

I will be capturing enough info to cite things properly, I think, though it gets much more complex when you have to deal with journal articles, internet sources, book chapters, etc. in addition to plain old books. The way I'm doing it now is that I'll capture standard publishing info in the WORK model (publisher, publication year, publication place, pages, etc. etc.) and then 'theme' that info based on a 'type' field. Not ideal, in many ways, but workable for now, since most of my stuff will be pretty standard.

I guess my goal right now is just to get a barebones working model that will enable me to capture the research information I want to capture. In the process of building this very basic app, I'll gain some valuable Rails and Ruby experience. Then, I can go back into it little by little and make improvements. I've definitely thought about more advanced bibliography tools, user/collaboration models, etc., but that's all a bit too advanced for me right now. Maybe when I have something that works I'll make a project out of it so people with more knowhow can contribute to it. Because you're right, it is something that could be very useful.

Thanks again...

Re: Modeling a Research App

If you list out your requirements it may help. Specifically regarding the "quote" model. From the above, I'm guessing the main problem with the first schema is you do not know which author the "quote" is from because the work has many authors? But you sometimes want to quote a specific work instead of just the author, correct? Do you ever need to specify both? "This quote was from this author in this work".

czheng wrote:

* this is the part that isn't on that wiki page, and which I'd like to know if it will work: QUOTES still belongs_to WORKS and WORKS still has_many quotes.

I'm not sure why this last point is necessary, can't the quotes for a given work be fetched through the attributions?

Railscasts - Free Ruby on Rails Screencasts

Re: Modeling a Research App

You're definitely helping me to clarify. Let me see if I can make sense of this... The authors of a quote should be directly inherited from its parent work. So there would never be confusion as to whom the author is, because if it comes from a particular book or essay (Work), the author(s) of that Work are the authors of the Quote. No ambiguity. So maybe I don't need Authors to have any direct relationship with Quotes as long as they're indirectly fetchable through the intermediary (Works).

I think I'll need to go with something like the second solution because I realize now that I need a join model between Authors and Works, since there can be a few different types of authorship or attribution(author, editor, translator, etc.). But I won't make Attributions polymorphic because I do need Quotes to belong directly and unambiguously to a Work (and I don't necessarily need them to belong to an Author). So last question, I think:

If I have a many-to-many relationship between Authors and Works through Attributions like this (and Quotes still belongs_to Works):

Authors --> Attributions <-- Works (<-- Quotes)

Will I still be able to fetch an author's quotes and a quote's author(s)?

(And thanks so much for all the help so far)

Last edited by czheng (2007-02-20 14:09:51)

Re: Modeling a Research App

czheng wrote:

If I have a many-to-many relationship between Authors and Works through Attributions like this (and Quotes still belongs_to Works):

Authors --> Attributions <-- Works (<-- Quotes)

Will I still be able to fetch an author's quotes and a quote's author(s)?

I don't think has_many :through goes beyond one level deep, but you should still be able to fetch those by creating your own custom methods (exactly the same way as described above). As long as attribution isn't polymorphic that is.

Railscasts - Free Ruby on Rails Screencasts

Re: Modeling a Research App

Perfect. No, attribution won't be polymorphic, so I'll go ahead and set it up this way, and use those custom methods you so kindly shared above.

Thanks for all your help!

Posts [ 10 ]

Pages 1