# Google Base... in Rails?

**URL:** <https://www.ruby-forum.com/t/google-base-in-rails/57468>\
**Category:** Rails\
**Created:** [April 11, 2006, 9:19am UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468 "2006-04-11T09:19:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 11, 2006, 9:19am UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/1 "2006-04-11T09:19:50Z")

</div>

Ok, so this is kinda out of the blue… but I’ve been looking at  
Google Base and thinking that it’s got some really good ideas in it.  
Especially the way you can create your own “type” of item with its own  
custom attributes, like date range, location, number, text, etc. Kind  
of like defining a database with a GUI, but not exactly.

It seems really interesting to me, from a sort of content management  
perspective. The hardest part for me is getting my head around how  
you’d structure the database tables to do this. It’s a lot like making  
an application that lets users build their own surveys, if that makes  
sense. Is anyone working on something remotely like this?

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 11, 2006, 9:22am UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/2 "2006-04-11T09:22:59Z")

</div>

in essence…

table Models

table Fields

class Model \< AR, etc  
has\_many :fields

end

On Tuesday, April 11, 2006, at 12:17 AM, Raymond B. wrote:

> sense. Is anyone working on something remotely like this?
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Mikkel B.

www.strongside.dk - Football Portal(DK)  
ting.minline.dk - Buy Old Stuff!(DK)

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 11, 2006, 9:30am UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/3 "2006-04-11T09:30:39Z")

</div>

Mikkel B. wrote:

> in essence…
> 
> table Models
> 
> table Fields
> 
> class Model \< AR, etc  
> has\_many :fields
> 
> end
> 
> On Tuesday, April 11, 2006, at 12:17 AM, Raymond B. wrote:
> 
> > sense. Is anyone working on something remotely like this?
> > 
> > * * *
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> Mikkel B.
> 
> www.strongside.dk - Football Portal(DK)  
> ting.minline.dk - Buy Old Stuff!(DK)

> **[dabbleDB](https://dabbledb.com/)**
>
> Stay at the forefront of innovation with DabbleDB - Your go-to source for all things tech and entertainment.

There is one written in rails, but it isn’t so good and I can’t remember  
the url.

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 11, 2006, 12:52pm UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/4 "2006-04-11T12:52:13Z")

</div>

On 11/04/2006, at 7:17 PM, Raymond B. wrote:

> It seems really interesting to me, from a sort of content management  
> perspective. The hardest part for me is getting my head around how  
> you’d structure the database tables to do this. It’s a lot like making  
> an application that lets users build their own surveys, if that makes  
> sense. Is anyone working on something remotely like this?

I’m working on something that’s very vaguely similar. It’s not of the  
scaled that Google Base is, but the fields can contain various types  
of data.

The easiest way is to have two tables, on with field descriptions and  
one with data. However, when a customer calls up asking you to do a  
complex data query it gets tricky. I’ve come up with a postgresql  
specific system that dynamically creates and modifies the data  
storage tables for each user. It’s probably far more complicated than  
it needs to be and a bit fragile in some places, but it works. As a  
bonus it gives you a real ActiveRecord object, though you can’t use  
the association methods.

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 13, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/5 "2006-04-13T16:33:09Z")

</div>

> There is one written in rails, but it isn’t so good and I can’t remember  
> the url.

Hi Joey,

Do you mean [http://www.myowndb.com](http://www.myowndb.com) ?  
Why the not so good? Let me know, I’m interested! ( You’re the first  
negative comment I see about the app.)

It’s in full development and has had some additions since the  
announcement (see [Index of /blog](http://www.myowndb.com/blog/) )

Cheers

Raph

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 13, 2006, 4:20pm UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/6 "2006-04-13T16:20:49Z")

</div>

On 4/11/06, Phillip H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The easiest way is to have two tables, on with field descriptions and  
> one with data.

The problem I’m having trouble getting my head around - or finding  
code samples for - is letting folks create their own data set. Let’s  
call it a Survey. I want users to be able to create any number of  
Surveys, each of which contain a number of “rows” just like in a  
database. How would you store the fact that one survey “question”  
takes a text area, and one takes a date, and one takes an integer,  
etc.?

Can anybody suggest a not-so-fragile, best-practice way of tackling  
something like this in a database?

---

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [April 13, 2006, 7:36pm UTC](https://www.ruby-forum.com/t/google-base-in-rails/57468/7 "2006-04-13T19:36:22Z")

</div>

class Set \< ActiveRecord:Base  
has\_many :rows  
end

class Row \< ActiveRecord:Base  
belongs\_to :set

# has an id, a type, a Text field called “value”

end

class IntegerRow \< Row  
def value  
super.value.to\_i  
end  
def value=(input)  
super.value = input.to\_s  
end  
end

class TextRow \< Row  
#no accessors needed  
end

So, basically what we are using is the subclass idea built into Rails.  
There  
are only two tables in the db in this example, but “types” associated  
with  
each row. In my super-simple example, a TypeRow is just an accessor  
wrapper  
around a Text field in the db that does converstion.

You won’t have the smallest DB in the world and you couldn’t do built-in  
db  
calculations on numbers.

But, otherwise you could go crazy defining rows… “PersonRow” could  
return  
a first and last name, etc.

-hampton.

-hampton.
