schema for straw (rss aggregator)

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 :slight_smile:

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/ 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/

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

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 :slight_smile:

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

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 );''')

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

Fred

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

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