 	centroid_media_id       int     null references media on delete cascade
 );
 CREATE INDEX media_clusters_runs_id on media_clusters(media_cluster_runs_id);
-
-create table media_clusters_media_map (
-    media_clusters_media_map_id     serial primary key,
-	media_clusters_id               int   not null references media_clusters on delete cascade,
-	media_id		                int   not null references media on delete cascade
-);
-
-create index media_clusters_media_map_cluster on media_clusters_media_map (media_clusters_id);
-create index media_clusters_media_map_media on media_clusters_media_map (media_id);
-
-create table media_cluster_words (
-	media_cluster_words_id	serial	primary key,
-	media_clusters_id       int	    not null references media_clusters on delete cascade,
-    internal                boolean not null,
-	weight			        float	not null,
-	stem			        text	not null,
-	term                    text    not null
-);
-
-create index media_cluster_words_cluster on media_cluster_words (media_clusters_id);
-
-/****************************************************** 
- * Jon's table for storing links between media sources
- *  -> Used in Protovis' force visualization. 
- ******************************************************/
-
-create table media_cluster_links (
-  media_cluster_links_id    serial  primary key,
-  media_cluster_runs_id	    int	    not null     references media_cluster_runs on delete cascade,
-  source_media_id           int     not null     references media              on delete cascade,
-  target_media_id           int     not null     references media              on delete cascade,
-  weight                    float   not null
-);
-
-/****************************************************** 
- * A table to store the internal/external zscores for
- *   every source analyzed by Cluto
- *   (the external/internal similarity scores for
- *     clusters will be stored in media_clusters, if at all)
- ******************************************************/
-
-create table media_cluster_zscores (
-  media_cluster_zscores_id  serial primary key,
-	media_cluster_runs_id	    int 	 not null     references media_cluster_runs on delete cascade,
-	media_clusters_id         int    not null     references media_clusters     on delete cascade,
-  media_id                  int    not null     references media              on delete cascade,
-  internal_zscore           float  not null, 
-  internal_similarity       float  not null,
-  external_zscore           float  not null,
-  external_similarity       float  not null     
-);
-
    
 /* 
 sets of media sources that should appear in the dashboard


alter table media_cluster_runs add constraint media_cluster_runs_state check (state in ('pending', 'executing', 'completed'));

create table media_cluster_maps (
    media_cluster_maps_id       serial          primary key,
    map_type                    varchar(32)     not null default 'cluster',
    json                        text            not null,
    nodes_total                 int             not null,
    nodes_rendered              int             not null,
    links_rendered              int             not null,
    media_cluster_runs_id       int             not null references media_cluster_runs on delete cascade
);
    
alter table media_cluster_maps add constraint media_cluster_maps_type check( map_type in ('cluster', 'polar' ));

create index media_cluster_maps_run on media_cluster_maps( media_cluster_runs_id );

create table media_cluster_map_poles (
    media_cluster_map_poles_id      serial      primary key,
    name                            text        not null,
    media_cluster_maps_id           int         not null references media_cluster_maps on delete cascade,
    pole_number                     int         not null,
    queries_id                      int         not null references queries on delete cascade
);

create index media_cluster_map_poles_map on media_cluster_map_poles( media_cluster_maps_id );

create table media_clusters (
	media_clusters_id		serial	primary key,
	media_cluster_runs_id	int	    not null references media_cluster_runs on delete cascade,

    stories_id int                not null references stories on delete cascade,
    state      authors_stories_queue_type not null
);
   
create table queries_dashboard_topics_map (
    queries_id              int                 not null references queries on delete cascade,
    dashboard_topics_id     int                 not null references dashboard_topics on delete cascade
