hi, for some purpose, I need a "in-javascript database", maybe built with some Prototype $H function calls for creating "tables" but what about junction tables, I mean those which express many-to- many relations between two entity tables ? I though using concatenation of strings with a separator, for example "key1 key2" "1234-56" or "ABC \n 789" but is it a really good way to do this ? could Prototype''s Hash or Enumerable be useful for that ? regards, Hefeust www.eozine.fr --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I guess you could try implementing a table data structure with Hash instances but its performance will most likely be weak. It would make sense to try to use DOM built-in API for working with tabular data - using table element. Such implementation could encapsulate an actual table and provide a convenient interface on top of that. Another option would be to use google gears. http://code.google.com/apis/gears/ - kangax On May 22, 6:39 pm, hefeust <hefe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > > for some purpose, I need a "in-javascript database", maybe built with > some Prototype $H function calls for creating "tables" > but what about junction tables, I mean those which express many-to- > many relations between two entity tables ? > > I though using concatenation of strings with a separator, for example > "key1 key2" > "1234-56" > or "ABC \n 789" > but is it a really good way to do this ? > > could Prototype''s Hash or Enumerable be useful for that ? > > regards, > > Hefeustwww.eozine.fr--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
than for the reply ok I''ll try Google Gears or others but my needs are not playing with DOM table but rather store tags/ articles in a way that I could count : 1 - total number of articles per tag 2 - number of articles sharing each given pair of tag so it can be build with 3 tables : ARTICLE(id_article, title, summarize) TAGS(id_tag, text) and a crossing table : ARTICLES_TAGS(id_article, id_tag) as it can be easily writing in ordinary SQL my implementation with be client-side javascript and have to be simpliest (and simpler than a complete set of DAO / ActiveRecord classes...) have you any more idea ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
What kind of numbers are we talking about here? E.g., numbers of articles, and numbers of tags? It''s just, #1 is pretty straightforward, but #2 will require rather a bit more work. Meanwhile, I haven''t looked at it much, but there are things like TrimQuery: http://code.google.com/p/trimpath/wiki/TrimQuery It''s an SQL engine subset written entirely in JavaScript and intended for use in the browser. A Google search for "+sql +javascript" should reveal other options as well. Hope this helps, -- T.J. Crowder tj / crowder software / com On May 24, 6:44 am, hefeust <hefe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> than for the reply > > ok I''ll try Google Gears or others > but my needs are not playing with DOM table but rather store tags/ > articles in a way that I could count : > 1 - total number of articles per tag > 2 - number of articles sharing each given pair of tag > > so it can be build with 3 tables : > > ARTICLE(id_article, title, summarize) > TAGS(id_tag, text) > and a crossing table : > ARTICLES_TAGS(id_article, id_tag) > > as it can be easily writing in ordinary SQL > > my implementation with be client-side javascript and have to be > simpliest (and simpler than a complete set of DAO / ActiveRecord > classes...) > > have you any more idea ?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
this is surely not optimal withit works pretty fine : var HashCounter = Class.create(Hash, { initialize : function( $super ) { $super( {} ); }, store: function(data) { found = this.seek(data); if( !found) { newid = (this.keys().map(parseInt).max() || 0) + 1; this.set(newid, $H( {id : newid, data: data, count: 1} )); } else { var id = found.get(''id''); var newcount = 1 + found.get(''count''); this.set(id, $H( {id: id, count: newcount, data: data} )); } }, seek: function(data) { var pair = this.detect( function(entry) { return data == entry[1].get(''data''); }); return pair ? pair[1] : false; }, toString : function() { var text = "toString\n"; this.each( function(pair) { text += pair.key + '' => '' + pair.value.get(''data'') + '' ('' + pair.value.get(''count'') + '')\n''; }); return text; } }); // -- USAGE // var Tags = new HashCounter(); // Tags.store(''abc''); // Tags.store(''abc''); // Tags.store(''def''); // -- displayed with Firebug console // console.log(Tags.toString()); it is the first step for building javascript cloud tags parsing an Ajax string like ARTICLE1_TITLE TAG1, TAG2, TAG3 ARTICLE2_TITLE TAG4, TAG5, TAG1 ARTICLE3_TITLE TAG6, TAG7, TAG2, TAG3 (a big list...) the number I attemp to compute is the STRENGTH of the coupling between all possible pair of tags : e.g. given a pair of tags, find the number of articles sharing this pair for example strength(TAG1, TAG7) = 0 strength(TAG2, TAG3) = 2 because of ARTICLE1 and ARTICLE3 strength(TAG1, TAG2) = 1 * etc, for all pairs --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
ooops ! it''s not as fine as i saidd i m refactorying the code at the moment but the objective is the same ! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Did you look a TrimQuery and rule it out? If so, I''d be interested in why (not a dig, seriously) -- was it too big (49k), too difficult to integrate, not powerful/flexible enough, etc., etc. -- T.J. Crowder tj / crowder software / com On May 28, 7:57 am, hefeust <hefe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ooops ! > it''s not as fine as i saidd > i m refactorying the code at the moment > but the objective is the same !--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Arghh ! this query engine is nice but I''m thinking is too generic and weighty for my needs (SQL speaking:) INSERT, SELECt, JOIN, COUNT are enough but kangax is right : prototype.Hash is weaker if used as a table maybe writing a table object encapsulting a array of records (Hashes or JSON) a Statement Object and a ResultSet one ? but keeping it simple ! a complete ORM is too much a brief description of what I''m doing is available on my site www.eozine.fr/trigradyn/ for the moment explanation are in french (a english summarize sooner...) but I hope there are enough drawings/schemas for being understanded by english readers ! Regards Hefeust --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Note : TriGraDyn stands for ''Trieur Graphique Dynamique'' which means ''Dynamic and Graphical Sorter '' (of data, of course) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
finally, I have made a fallback to ordinary arrays, storing objects like : 0 => { tag : "lion", count : 10 } 1 => { tag : ''''cat'', count : 4 } or for association table : { id_article : 0, id_tag : 0} { id_article : 0, id_tag : 1} using array indexes as id''s Prototype is commun with Array#select method which is useful and can be used as a customisable database SQL SELECT statement Thanks for your views (advice) demo is visible at www.eozine.fr/trigradyn/ links at the bottom of the page --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---