扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Martin Streicher 来源:论坛整理 2007年10月21日
关键字:
CREATE TABLE Inventory ( id int(10) unsigned NOT NULL auto_increment, partno varchar(32) NOT NULL, description varchar(256) NOT NULL, price float unsigned NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY partno USING BTREE (partno) ) ENGINE=InnoDB; |
INSERT INTO `Inventory` (`id`, `partno`, `description`, `price`) VALUES (1,'WIN408','Portal window',423), (2,'ACC711','Jack kit',110), (3,'ACC43','Rear-view mirror',55), (4,'ACC5409','Cigarette lighter',20), (5,'WIN958','Windshield, front',500), (6,'765432','Bolt',0.1), (7,'ENG001','Entire engine',10000), (8,'ENG088','Cylinder head',55), (9,'ENG976','Large cylinder head',65); |
CREATE TABLE Schematic ( id int(10) unsigned NOT NULL auto_increment, partno_id int(10) unsigned NOT NULL, assembly_id int(10) unsigned NOT NULL, model_id int(10) unsigned NOT NULL, PRIMARY KEY (id), KEY partno_index USING BTREE (partno_id), KEY assembly_index USING BTREE (assembly_id), KEY model_index USING BTREE (model_id), FOREIGN KEY (partno_id) REFERENCES Inventory(id), FOREIGN KEY (assembly_id) REFERENCES Assembly(id), FOREIGN KEY (model_id) REFERENCES Model(id) ) ENGINE=InnoDB; |
INSERT INTO `Schematic` (`id`, `partno_id`, `assembly_id`, `model_id`) VALUES (1,6,5,1), (2,8,5,1), (3,1,3,1), (4,5,3,1), (5,8,5,7), (6,6,5,7), (7,4,7,3), (8,9,5,3); |
source catalog { type = mysql sql_host = localhost sql_user = reaper sql_pass = s3cr3t sql_db = body_parts sql_sock = /var/run/mysqld/mysqld.sock sql_port = 3306 |
CREATE OR REPLACE VIEW Catalog AS SELECT Inventory.id, Inventory.partno, Inventory.description, Assembly.id AS assembly, Model.id AS model FROM Assembly, Inventory, Model, Schematic WHERE Schematic.partno_id=Inventory.id AND Schematic.model_id=Model.id AND Schematic.assembly_id=Assembly.id; |
mysql> use body_parts; Database changed mysql> select * from Catalog; +----+---------+---------------------+----------+-------+ | id | partno | description | assembly | model | +----+---------+---------------------+----------+-------+ | 6 | 765432 | Bolt | 5 | 1 | | 8 | ENG088 | Cylinder head | 5 | 1 | | 1 | WIN408 | Portal window | 3 | 1 | | 5 | WIN958 | Windshield, front | 3 | 1 | | 4 | ACC5409 | Cigarette lighter | 7 | 3 | | 9 | ENG976 | Large cylinder head | 5 | 3 | | 8 | ENG088 | Cylinder head | 5 | 7 | | 6 | 765432 | Bolt | 5 | 7 | +----+---------+---------------------+----------+-------+ 8 rows in set (0.00 sec) |
# indexer query # document_id MUST be the very first field # document_id MUST be positive (non-zero, non-negative) # document_id MUST fit into 32 bits # document_id MUST be unique sql_query = \ SELECT \ id, partno, description, \ assembly, model \ FROM \ Catalog; sql_group_column = assembly sql_group_column = model # document info query # ONLY used by search utility to display document information # MUST be able to fetch document info by its id, therefore # MUST contain '$id' macro # sql_query_info = SELECT * FROM Inventory WHERE id=$id } |
index catalog { source = catalog path = /var/data/sphinx/catalog morphology = stem_en min_word_len = 3 min_prefix_len = 0 min_infix_len = 3 } |
source catalog { type = mysql sql_host = localhost sql_user = reaper sql_pass = s3cr3t sql_db = body_parts sql_sock = /var/run/mysqld/mysqld.sock sql_port = 3306 # indexer query # document_id MUST be the very first field # document_id MUST be positive (non-zero, non-negative) # document_id MUST fit into 32 bits # document_id MUST be unique sql_query = \ SELECT \ id, partno, description, \ assembly, model \ FROM \ Catalog; sql_group_column = assembly sql_group_column = model # document info query # ONLY used by search utility to display document information # MUST be able to fetch document info by its id, therefore # MUST contain '$id' macro # sql_query_info = SELECT * FROM Inventory WHERE id=$id } index catalog { source = catalog path = /var/data/sphinx/catalog morphology = stem_en min_word_len = 3 min_prefix_len = 0 min_infix_len = 3 } searchd { port = 3312 log = /var/log/searchd/searchd.log query_log = /var/log/searchd/query.log pid_file = /var/log/searchd/searchd.pid } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者