Bibtex database design


#1

I am working a Bibtex database for my school using Rails and I need some
idea
on how to manage the bibtex types.

I crated an Author and Publications model and put
has_and_belongs_to_many
relationship between them.

The user model basically is like this:

class User < ActiveRecord::Base
has_and_belongs_to_many :publications

end

The Publication model has all the Bibtex fields and I use STI for
managing the
bibtex types like:

class Publication < ActiveRecord::Base
has_and_belongs_to_many :users
end

class Article < Publication
# An article from a journal or magazine. Required fields:
author,
title, journal, year.
# Optional fields: volume, number, pages, month, note.
validates_presence_of :title, :journal, :year
end
end

class Book < Publication
# A book with an explicit publisher. Required fields: author or
# editor, title, publisher, year.
# Optional fields: volume or number, series, address, edition,
month,
# note.
validates_presence_of :title, :publisher, :year
end

class Booklet < Publication
# A work that is printed and bound, but without a named
publisher or
sponsoring institution.
# Required field: title. Optional fields: author, howpublished,
address, month, year, note.
validates_presence_of :title
end
class InBook < Publication
# A part of a book, which may be a chapter (or section or
whatever)
and/or a range of pages.
# Required fields: author or editor, title, chapter and/or
pages,
publisher, year.
# Optional fields: volume or number, series, type, address,
edition,
month, note.
validates_presence_of :title, :chapter, :pages, :publisher,
:year
end

class InCollection < Publication
# A part of a book having its own title. Required fields:
author,
title, booktitle, publisher, year.
# Optional fields: editor, volume or number, series, type,
chapter,
pages, address, edition, month, note.
validates_presence_of :title, :booktitle, :publisher, :year
end

class InProceedings < Publication
# An article in a conference proceedings. Required fields:
author,
title, booktitle, year.
# Optional fields: editor, volume or number, series, pages,
address,
month, organization, publisher, note.
validates_presence_of :title, :booktitle, :year
end

Now this is ok but in the view part I want to create a form that would
display
certain fields based on the publication type. For example Article has
some
required, optional and ignored fields. I want the view (Create/Edit) to
show
only those attributes relevant to a publication class.

I tried overriding the content_columns but in console I get a stack too
deep
error or segfaults sometimes.

I tried this

class Article < Publication
validates_presence_of :title, :journal, :year

    def self.content_columns
            return Article.content_columns.delete_if {|c|

[“publisher”].include?(c.name) }
end
end

Any ideas on how to do this without having to create a different view
for each
publication type?

regards,
Horacio


#2

Horacio S. wrote:

Now this is ok but in the view part I want to create a form that would
display
certain fields based on the publication type. For example Article has
some
required, optional and ignored fields. I want the view (Create/Edit) to
show
only those attributes relevant to a publication class.

I tried overriding the content_columns but in console I get a stack too
deep
error or segfaults sometimes.

I tried this

class Article < Publication
validates_presence_of :title, :journal, :year

    def self.content_columns
            return Article.content_columns.delete_if {|c|

[“publisher”].include?(c.name) }
end
end

Any ideas on how to do this without having to create a different view
for each
publication type?

regards,
Horacio

You can do some if…then (or case…when) conditionals in the view which
depends on the publication type.

you can probably put in things like…

<%= text_field(‘name’,‘id’) if @object.isa? Book -%>

_Kevin


#3

Horacio S. <hsanson@…> writes:

I am working a Bibtex database for my school using Rails and I need some idea
on how to manage the bibtex types.

I crated an Author and Publications model and put has_and_belongs_to_many
relationship between them.

Since I think about this issue a lot, I’d like to prompt you to consider
whether you really want to base this on BibTeX, which has a poor
data model.

So rather than Author, how about Agent, and then have two
subclasses: Person and Organization.

You then relate those agents to Reference objects (which can be more
than just publications) through a HABTM join.

The reason is that I might be an author of one work, an editor of
another, and a translator of still another. Likewise, there are
organizational authors, and organizations also have other roles
(like publishers).

Other important classes and subclasses:

Event
Conference < Event
Hearing < Event
Publisher < Organization
Collection
Series < Collection
Periodical < Collection

So you can then think about relations like:

[Reference with type of “paper”]
authored by --> [Person “Jane Doe”]
presented at --> [Conference “ABC Conference”]
published in --> [Proceeedings “Proceedings of ABC Conference”]
published by --> [Publisher “XYZ Publishing”]

I tend to think that parts (article, chapters, etc.) might well be
stored in
the same table, but am not sure. I think reference types probably ought
to just be stored in a separate table for flexibility’s sake.

Just a thought …

Bruce


#4

Thanks, I would really like to use a model different from the Bibtex
one.
Unfortunately the database is a legacy one in Bibtex format and has all
publications of my school since 1977 (quite a lot).

Changing the model may be a real challenge (Migrations maybe?). Anyway I
like
this idea of Events, Agents and Organizations… I will look into it.

For now I will simply create a single View that displays the fields
depending
on the Class (subclass).

Horacio

Tuesday 24 January 2006 00:17ã?Bruce D’Arcus ã?ã??はæ?¸ãã¾ã?ã?:


#5

maybe you could use yaml to store it all in one coumn.
One filld could be the type - inproceedings/artcle/… and the rest of
the
fields would just be in the yaml. then you could construct the right
kind
of object