database - How do I setup keywords in this case? -


i making db hold drawings / files / notes or links these items. i'm making program let user type in keyword , give them links drawings/ files/ or notes. i'm not sure how store keywords , still have fast enough work.

example table main id  area  type  specific  file  keywords 1   rx1    icc   tester   ..    lock, sg1, va2, cn1, cn2, sgp, vu, boof 2   rx1    ecu   tester   ..    sg1 , ba3, yys, yyz, yyx, lock 3   rx3    ecu   control  ..    sg2, sg3, va2, yys etc....  

so user select area type specific, , type in keyword results. there 10,000 rows. , keywords anywhere 1 200.

second can done in ms access db? know access has limits it's have installed , used working with.

don't keep keywords in main table. instead, keep keyword table , filetokeyword table many many relationship. have no limit number of keywords each item.

your primary key table should both columns (fileid, keywordid) , search 3-table join.

i answered similar question yesterday

table examples per request in comments:

table main ---------- id  area  type  specific  file 1   rx1    icc   tester   .. 2   rx1    ecu   tester   .. 3   rx3    ecu   control  ..   table keywords -------------- keyword_id  keyword_text 1           lock 2           sg1 3           va2 4           cn1 5           cn2 6           sgp  table filetokeyword ------------------- fileid   keywordid 1        1 1        2 1        3 1        4 1        5 1        6 2        1 2        3 

notes:
in keywords table

  • keyword_id primary key
  • keyword_text unique

in filetokeyword table

  • fileid foreign key table main
  • keywordid foreign key table keywords
  • the combination of both columns primary key

your select should this:

select id, area, type, specific, file main inner join filetokeyword on(id = fileid) inner join keywords on(keywordid = keyword_id) keyword_text in('lock', 'sg1') , area = 'rx1' -- other conditions might want add 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -