# Schema for straw (rss aggregator)

**URL:** <https://www.ruby-forum.com/t/schema-for-straw-rss-aggregator/120747>\
**Category:** Rails\
**Created:** [November 20, 2007, 10:45am UTC](https://www.ruby-forum.com/t/schema-for-straw-rss-aggregator/120747 "2007-11-20T10:45:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 20, 2007, 10:45am UTC](https://www.ruby-forum.com/t/schema-for-straw-rss-aggregator/120747/1 "2007-11-20T10:45:12Z")

</div>

I would like to build an application on top of the following schema,  
but,  
of course, it would be preferable to make the schema compatible with the  
rails naming conventions so that things work as smoothly as possible 🙂

The current schema for straw:

85 dbSql = []

86

87 dbSql.append(‘’’

88 CREATE TABLE IF NOT EXISTS feeds (

89 id INTEGER PRIMARY KEY,

90 title TEXT,

91 location VARCHAR(255),

92 category\_id INTEGER

93 );‘’');

94

95 dbSql.append(‘’’

96 CREATE TABLE IF NOT EXISTS items (

97 id INTEGER PRIMARY KEY,

98 title TEXT NOT NULL,

99 feed\_id INTEGER NOT NULL,

100 is\_read INTEGER NOT NULL DEFAULT 0,

101 link TEXT NOT NULL,

102 pub\_date TIMESTAMP NOT NULL,

103 description TEXT NOT NULL

104 );‘’')

105

106 dbSql.append(‘’’

107 CREATE TABLE IF NOT EXISTS categories (

108 id INTEGER PRIMARY KEY,

109 parent\_id INTEGER,

110 title TEXT

111 );‘’')

112

113 dbSql.append(‘’‘INSERT INTO categories (parent\_id, title) VALUES  
(NULL, ‘root’);’‘’)

114

115 dbSql.append(‘’’

116 CREATE TABLE IF NOT EXISTS treeview\_nodes (

117 id INTEGER PRIMARY KEY,

118 obj\_id INTEGER NOT NULL,

119 norder INTEGER NOT NULL,

120 type VARCHAR(1) NOT NULL

121 );‘’')

\<[http://repo.or.cz/w/straw/fork.git?a=blob;f=straw/storage/](http://repo.or.cz/w/straw/fork.git?a=blob;f=straw/storage/)  
SQLiteStorage.py;h=aeb1fc418c162bdc082d8bcc7dbc6a8e1af9b2a5;hb=dfaf7eb7f1206746a2d8d43be0e81ed396ef711c\>

I don’t really have enough knowledge as to what specific changes to  
propose. The tables look to be plurals, which is good, I know.  
According to \<[http://wiki.rubyonrails.org/rails/pages/](http://wiki.rubyonrails.org/rails/pages/)  
TipSheetForBeginners\> this is pretty much the only schema requirement.

Would this qualify as a legacy database? If so, why and what can be  
done  
to change that?

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 20, 2007, 10:51am UTC](https://www.ruby-forum.com/t/schema-for-straw-rss-aggregator/120747/2 "2007-11-20T10:51:02Z")

</div>

On 20 Nov 2007, at 09:36, Thufir wrote:

> I would like to build an application on top of the following schema,  
> but,  
> of course, it would be preferable to make the schema compatible with  
> the  
> rails naming conventions so that things work as smoothly as  
> possible 🙂

this seems mostly sensible. as you say the table names are plural and  
the foreign key columns are of the form singular-table\_id.

The one thing that is nonstandard

> 120 type VARCHAR(1) NOT NULL
> 
> 121 );’’’)

By default activerecord uses the type column for single table  
inheritance. You can of course change this

Fred

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 20, 2007, 11:10am UTC](https://www.ruby-forum.com/t/schema-for-straw-rss-aggregator/120747/3 "2007-11-20T11:10:59Z")

</div>

On Tue, 20 Nov 2007 09:50:10 +0000, Frederick C. wrote:

> The one thing that is nonstandard
> 
> > 116 CREATE TABLE IF NOT EXISTS treeview\_nodes (  
> > […]  
> > By default activerecord uses the type column for single table  
> > inheritance. You can of course change this

Ahem, pretend this is a bit new for me:  
What do you mean by type column? What do you mean by single table  
inheritance?

What if that table name were changed to either “views” or “nodes” or  
“TreeViewNodes” or similar? Or was it the name of the fields for this  
table?

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 20, 2007, 11:32am UTC](https://www.ruby-forum.com/t/schema-for-straw-rss-aggregator/120747/4 "2007-11-20T11:32:41Z")

</div>

On 20 Nov 2007, at 10:09, Thufir wrote:

> > inheritance. You can of course change this
> 
> Ahem, pretend this is a bit new for me:  
> What do you mean by type column? What do you mean by single table  
> inheritance?  
> Well you’ve got a column called ‘type’. I’ll leave it up to you to  
> google single table inheritance but the short version is that when you  
> call Product.find(123) you get back a subclass of product. Rails uses  
> the value of the type column to decide what class to instantiate.

Fred
