僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。
自分自身のキーになるIDと、別項目のIDを照らし合わせる、らしい。
sqlite> .schema self_ref CREATE TABLE self_ref(id integer primary key, superior_id integer, animal text);
sqlite> select * from self_ref; id superior_id anim ---- ------------- ---- 1 ヒト 2 1 サメ 3 2 マグロ 4 3 カツオ 5 4 アジ
sqlite> select s1.id ID , s1.animal NAME , s2.animal SUPERIOR from self_ref s1 > inner join self_ref s2 on s1.superior_id = s2.id; ID NAME SUPE ---- ------------- ---- 2 サメ ヒト 3 マグロ サメ 4 カツオ マグロ 5 アジ カツオ
IDと、名前と、従属を示すIDがあれば、多少違う属性のデータであっても 同じカラムに放り込めるらしい。で、それを 違う形に仕上げると。
複数のテーブルを横に、でなく縦に繋ぐ。
この場合、カラムの数を(それ以外も?)揃える。
sqlite> .schema first CREATE TABLE first (id integer primary key, name text); sqlite> .schema second CREATE TABLE second (id integer primary key, name text, name2 text);
sqlite> select * from first; id name ---- ------------- 1 foo 2 bar sqlite> select * from second; id name name ---- ------------- ---- 1 hoge ほげ 2 fuga ふが
sqlite> select * from first UNION select * from second; Error: SELECTs to the left and right of UNION do not have the same number of result columns sqlite> select * from first UNION select id, name from second; id name ---- ------------- 1 foo 1 hoge 2 bar 2 fuga
sqlite3はこんなのでも通ったが。
sqlite> select * from first UNION select name2, id from second; id name ---- ------------- 1 foo 2 bar ふが 2 ほげ 1
なんとかそれらしくできた。
実はまだ、計算してその都度アップデート、
なんてことはできていない。
あらかじめ登録したパターンの通りに光るだけで、
毎回ばらついて見えるようにできたか
どうか確認しきれてない。
その後、
スクリプトにeightqueenを追記した。
基本的なパターンが被ってる可能性はあるが、
毎回計算しているので、一応変化しているかのごとくに見えるようには、
なった。
今日はやめとく。
リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。