Created
May 27, 2010 03:12
-
-
Save amfeng/415398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENTITY book_lines | |
{ | |
int book_line_id, | |
string line, | |
int source, | |
int linenum, | |
int created_at, | |
int updated_at | |
PRIMARY(linenum, source) | |
} | |
ENTITY books | |
{ | |
int book_id, | |
string name, | |
int created_at, | |
int updated_at | |
PRIMARY(name) | |
} | |
ENTITY wordlists | |
{ | |
int wordlist_id, | |
string name, | |
string description, | |
int created_at, | |
int updated_at | |
PRIMARY(name) | |
} | |
ENTITY words | |
{ | |
int word_id, | |
string word, | |
string definition, | |
int created_at, | |
int updated_at | |
PRIMARY(word) | |
} | |
ENTITY words_wordlists | |
{ | |
int words_wordlist_id, | |
FOREIGN KEY word_word REF words MAX 10000, | |
FOREIGN KEY wordlist_name REF wordlists | |
PRIMARY(words_wordlist_id) | |
} | |
ENTITY wrong_choices | |
{ | |
int wrong_choice_id, | |
int count, | |
int created_at, | |
int updated_at, | |
FOREIGN KEY word_word REF words | |
PRIMARY(wrong_choice_id) | |
} | |
ENTITY context_caches | |
{ | |
int context_cache_id, | |
FOREIGN KEY word_word REF words, | |
bool dirty, | |
int created_at, | |
int updated_at | |
PRIMARY(context_cache_id) | |
} | |
ENTITY contexts | |
{ | |
int context_id, | |
string wordline, | |
string before, | |
string after, | |
int created_at, | |
int updated_at, | |
FOREIGN KEY book_name REF books, | |
FOREIGN KEY word_word REF words | |
PRIMARY(context_id) | |
} | |
ENTITY contexts_words | |
{ | |
int contexts_word_id, | |
FOREIGN KEY context REF contexts, | |
FOREIGN KEY word_word REF words | |
PRIMARY(contexts_word_id) | |
} | |
ENTITY game_players | |
{ | |
int game_player_id, | |
FOREIGN KEY user_login REF users MAX 1000, | |
FOREIGN KEY game REF games, | |
int score, | |
int created_at, | |
int updated_at | |
PRIMARY(user_login, game) | |
} | |
ENTITY multiple_choices | |
{ | |
int multiple_choice_id, | |
string choice1, | |
string choice2, | |
string choice3, | |
string choice4, | |
FOREIGN KEY word_word REF words, | |
int created_at, | |
int updated_at, | |
bool is_intersection, | |
int score | |
PRIMARY(multiple_choice_id) | |
} | |
ENTITY searches | |
{ | |
int searche_id, | |
int created_at, | |
int updated_at | |
PRIMARY(searche_id) | |
} | |
ENTITY users | |
{ | |
int user_id, | |
string login, | |
string name, | |
string email, | |
string crypted_password, | |
string salt, | |
int created_at, | |
int updated_at, | |
string remember_token, | |
int remember_token_expires_at, | |
string activation_code, | |
int activated_at | |
PRIMARY(login) | |
} | |
ENTITY games | |
{ | |
int game_id, | |
FOREIGN KEY wordlist_name REF wordlists, | |
bool finished, | |
FOREIGN KEY user_login REF users, | |
int created_at, | |
int updated_at, | |
string currentword | |
PRIMARY(game_id) | |
} | |
////****Explicit Find Calls**** | |
////BookLine.find(:all, :conditions => ["line like ?", "%" + query + "%"]) | |
//// QUERY bookLineQuery | |
//// FETCH book_lines | |
//// ??? | |
////BookLine.find(:first, :conditions => ["linenum = ? and source = ?", line.linenum - 1, line.source]) | |
QUERY bookLineBeforeAndAfter | |
FETCH book_lines | |
WHERE linenum = [1:linenum] AND source = [2:linesource] | |
LIMIT 1 MAX 1 | |
////Book.find(line.source) | |
QUERY bookByName | |
FETCH books | |
WHERE name = [1:bookname] | |
LIMIT 1 MAX 1 | |
////GamePlayer.find(:first, :conditions => {:game_id => game.id, :user_id => user_id}) | |
QUERY gamePlayerByGame | |
FETCH game_players | |
WHERE game = [1:game_id] AND user_login = [2:login] | |
LIMIT 1 MAX 1 | |
////Game.find(params[:id]) | |
QUERY gameById | |
FETCH games | |
WHERE game_id = [1:game_id] | |
LIMIT 1 MAX 1 | |
////MultipleChoice.find(params[:mc_id]) | |
QUERY multipleChoiceById | |
FETCH multiple_choices | |
WHERE multiple_choice_id = [1:mc_id] | |
LIMIT 1 MAX 1 | |
////User.find_by_login("guest") | |
QUERY userByLogin | |
FETCH users | |
WHERE login = [1:username] | |
LIMIT 1 MAX 1 | |
////Wordlist.all | |
QUERY allWordlists | |
FETCH wordlists | |
LIMIT 500 MAX 500 | |
////Wordlist.find(params[:id]) | |
QUERY wordlistByName | |
FETCH wordlists | |
WHERE name = [1:wordlist_name] | |
LIMIT 1 MAX 1 | |
////Word.find_by_word(game.currentword) | |
QUERY wordByWord | |
FETCH words | |
WHERE word = [1:word] | |
LIMIT 1 MAX 1 | |
////Word.all | |
QUERY allWords | |
FETCH words | |
LIMIT 1000 MAX 1000 | |
////Word.all(:order=>'RANDOM()', :limit=>4) | |
//// QUERY randomWords | |
//// FETCH words | |
//// ??? | |
// | |
////****Associations**** | |
// [[ DONT NEED ]] | |
////wordlist = game.wordlist.words | |
// QUERY wordlistFromGame | |
// FETCH wordlists | |
// OF games BY wordlist_name | |
// //WHERE games.game_id = [1:game] | |
// WHERE games = [this] | |
// LIMIT 1 MAX 1 | |
// | |
// [[ THIS IS BETTER, ALLOWS YOU TO DO wordlists.words() ]] | |
QUERY wordsFromWordlist | |
FETCH words | |
OF words_wordlists BY word_word | |
OF wordlists me BY wordlist_name | |
WHERE me = [this] | |
LIMIT 10000 MAX 10000 | |
// | |
////c.word = w; | |
//// ??? | |
////cc.word = w; | |
//// ??? | |
// | |
////w.contexts | |
QUERY contextsFromWord | |
FETCH contexts | |
OF words me BY word_word | |
WHERE me = [this] | |
LIMIT [1:count] MAX 100 | |
////w.context_cache | |
// [[ IF EACH WORD HAS EXACTLY ONE context_cache, CONSIDER MAKING IT A FK OF WORD ]] | |
QUERY contextCacheFromWord | |
FETCH context_caches | |
OF words me BY word_word | |
WHERE me = [this] | |
LIMIT 1 MAX 1 | |
// | |
////word.multiple_choices | |
QUERY multipleChoicesFromWord | |
FETCH multiple_choices | |
OF words me BY word_word | |
WHERE me = [this] | |
LIMIT [1:count] MAX 10 | |
//// | |
//////word.wrong_choices << WrongChoice.create(:wrong_choice_id => word.id) | |
////// ??? | |
//// | |
//////word.wrong_choices | |
QUERY wrongChoicesFromWord | |
FETCH wrong_choices | |
OF words me BY word_word | |
WHERE me = [this] | |
LIMIT [1:count] MAX 10 | |
//// | |
//////current_user.games | |
// QUERY gamesByUser | |
// FETCH games | |
// OF game_players BY game | |
// OF users me BY user_login | |
// WHERE me = [this] | |
// LIMIT [1:count] MAX 25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment