SQL for selecting triples inside of one field.

Just a programming note here so i won't forget this technique.  You can get the best of both the SQL and the triple world with this technique. 
  • assert name value triples into a the context of an array like 
    $_SESSION['things']['name']="value";
  • code the array in JSON with a command like
    $variable = json_encode ($_SESSION['things'])
  • Write the $variable into a SQL record in like a long field
  • Records where name=value can then be retrieved with the following query
    SELECT * FROM `whatever` where `variable` like "%name:value%"
Before i figured this out i would hesititate to add data to a record using just name/value pairs without adding a separate field just for each name.  Now i can have a large variable in a database and slush in new data without changeing the structure of the table and at the same time select out which records apply with SQL statements and not long loops through all the records.

Tags

  1. dev
  2. sql like
  3. programming
  4. triples
  5. json
  6. speaktomecatalog.com

Comments


Seth says
The relation between JSON and linked data (aka triples, semantic web, cybermind) is talked about here with the meet being here.  What that doesn't tell you is how easy the json_encode PHP function will map an internal array into what needs to written in a database.  Then too it doesn't solve the problem of how you select out of those triples just using SQL ... because that can get kind of knarley when you consider exploding triples into single records.  This item solves that problem.

Seth says

For example, to retrieve all the invoices where the last coupon was cashed you would go
SELECT * FROM `invoice` where `promotion` like '%cpon_ca_4%'
... and you would select out 35 invoices.  You could total those and find out that we paid a discount of about 7%.

Seth says

See Also

  1. Thought Getting a new emoticon at fastblogit with 34 viewings related by tag "dev".
  2. Thought about: GitHub - sait/vfpjson: Json encoder and decoder for VFP Visual Fox Pro with 25 viewings related by tag "json".
  3. Thought Footer problem on individual page at speaktomecatalog.com with 19 viewings related by tag "programming".
  4. Thought JasonLd with 14 viewings related by tag "json".
  5. Thought Json Browser with 11 viewings related by tag "Json".
  6. Thought about: Laughing Hillary Pen from Speak To Me Catalog with 9 viewings related by tag "speaktomecatalog.com".
  7. Thought Automating Selling on Amazon with 4 viewings related by tag "dev".
  8. Thought The CSS font-size statement does not work on the MacAir in Chrome with 4 viewings related by tag "dev".
  9. Thought Linking fastblogit tags to other sites with 4 viewings related by tag "dev".
  10. Thought What is the mentography of JSON ? with 4 viewings related by tag "json".
  11. Thought Speak To Me Catalog (Production of the Print Version) with 2 viewings related by tag "speaktomecatalog.com".
  12. Thought A sustainable fastblogit with 2 viewings related by tag "dev".
  13. Thought An enemy turns into a friend ... with 2 viewings related by tag "speaktomecatalog.com".
  14. Thought upload from computer to cartoon stopped working with 1 viewings related by tag "dev".
  15. Thought about: try ruby! (in your browser) with 1 viewings related by tag "programming".
  16. Thought Speak To Me Print Catalog with 1 viewings related by tag "speaktomecatalog.com".
  17. Thought renewal of ssl certificate for www.speaktomecatalog.com with 1 viewings related by tag "speaktomecatalog.com".
  18. Thought A Gremlin on your items ? with 1 viewings related by tag "dev".
  19. Thought some thoughts on trans domain data transfer with 1 viewings related by tag "programming".
  20. Thought [title (18144)] with 1 viewings related by tag "dev".
  21. Thought a good place to satisfy question~answer with 0 viewings related by tag "programming".
  22. Thought Facebook Ads with 0 viewings related by tag "speaktomecatalog.com".
  23. Thought about: template to start a new coupon with 0 viewings related by tag "speaktomecatalog.com".
  24. Thought Syndicating our products with 0 viewings related by tag "speaktomecatalog.com".
  25. Thought New coupon method request for our catalog ... with 0 viewings related by tag "speaktomecatalog.com".
  26. Thought about: hd radio give away! with 0 viewings related by tag "speaktomecatalog.com".
  27. Thought Google SEO for speaktomecatalog.com with 0 viewings related by tag "dev".
  28. Thought sources of php code with 0 viewings related by tag "programming".
  29. Thought about: speaktomecatalog.com | facebook with 0 viewings related by tag "speaktomecatalog.com".
  30. Thought about: Then each went to his own home with 0 viewings related by tag "programming".
  31. Thought Setting Time on the with 0 viewings related by tag "speaktomecatalog.com".
  32. Thought Simplifying URLs with 0 viewings related by tag "dev".
  33. Thought about: amazon.com at a glance: speak_to_me_catalog with 0 viewings related by tag "speaktomecatalog.com".
  34. Thought Black Friday with 0 viewings related by tag "speaktomecatalog.com".
  35. Thought Repeating Quads Structure on tagtalking dev blog with 0 viewings related by tag "dev".
  36. Thought PayPal with 0 viewings related by tag "speaktomecatalog.com".
  37. Thought sql explained for group tagroom with 0 viewings related by tag "programming".
  38. Thought related tags with 0 viewings related by tag "programming".
  39. Thought dynamic cartoons with 0 viewings related by tag "dev".
  40. Thought about: speaktomecatalog.com - web analysis with 0 viewings related by tag "speaktomecatalog.com".
  41. Thought deactivate HTML in comments - or how and where to escape with 0 viewings related by tag "programming".
  42. Thought propogate logic from front door to rooms and refactor with 0 viewings related by tag "programming".
  43. Thought Replacing live search with 0 viewings related by tag "dev".
  44. Thought A great little online png editor with 0 viewings related by tag "speaktomecatalog.com".
  45. Thought Building stufftalks.com with 0 viewings related by tag "dev".
  46. Thought Speak To Me Catalog TV Channel with 0 viewings related by tag "speaktomecatalog.com".
  47. Thought about: Final Results for 2006 Disabled Singing Contest with 0 viewings related by tag "speaktomecatalog.com".
  48. Thought ok here is the sizing algorithm that will go into testing with 0 viewings related by tag "programming".
  49. Thought about: George Bush Talking Opener with 0 viewings related by tag "speaktomecatalog.com".
  50. Thought Revision of our catalog request form with 0 viewings related by tag "dev".