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 61 viewings related by tag "dev".
  2. Thought about: GitHub - sait/vfpjson: Json encoder and decoder for VFP Visual Fox Pro with 33 viewings related by tag "json".
  3. Thought Speak To Me Print Catalog with 31 viewings related by tag "speaktomecatalog.com".
  4. Thought Speak To Me Catalog (Production of the Print Version) with 20 viewings related by tag "speaktomecatalog.com".
  5. Thought Footer problem on individual page at speaktomecatalog.com with 19 viewings related by tag "programming".
  6. Thought Enhancing Your Shopping Experience with YouTube Videos with 15 viewings related by tag "speaktomecatalog.com".
  7. Thought JasonLd with 14 viewings related by tag "json".
  8. Thought Json Browser with 13 viewings related by tag "Json".
  9. Thought about: Laughing Hillary Pen from Speak To Me Catalog with 10 viewings related by tag "speaktomecatalog.com".
  10. Thought Automating Selling on Amazon with 8 viewings related by tag "dev".
  11. Thought Promotions in the Speak To Me Catalog Shopping Basket with 6 viewings related by tag "programming".
  12. Thought about: SpeakToMeCatalog: free with 6 viewings related by tag "speaktomecatalog.com".
  13. Thought What is the mentography of JSON ? with 6 viewings related by tag "json".
  14. Thought The CSS font-size statement does not work on the MacAir in Chrome with 5 viewings related by tag "dev".
  15. Thought renewal of ssl certificate for www.speaktomecatalog.com with 4 viewings related by tag "speaktomecatalog.com".
  16. Thought Linking fastblogit tags to other sites with 4 viewings related by tag "dev".
  17. Thought A sustainable fastblogit with 3 viewings related by tag "dev".
  18. Thought about: Testing Spin To Win with 2 viewings related by tag "dev".
  19. Thought An enemy turns into a friend ... with 2 viewings related by tag "speaktomecatalog.com".
  20. Thought [title (18144)] with 2 viewings related by tag "dev".
  21. Thought Google SEO for speaktomecatalog.com with 1 viewings related by tag "dev".
  22. Thought about: Then each went to his own home with 1 viewings related by tag "programming".
  23. Thought Simplifying URLs with 1 viewings related by tag "dev".
  24. Thought upload from computer to cartoon stopped working with 1 viewings related by tag "dev".
  25. Thought G+ business page for SpeakToMeCatalog.com with 1 viewings related by tag "speaktomecatalog.com".
  26. Thought about: try ruby! (in your browser) with 1 viewings related by tag "programming".
  27. Thought many useful php routines with 1 viewings related by tag "programming".
  28. Thought unzip for install.php with 1 viewings related by tag "programming".
  29. Thought speak amazon store with 1 viewings related by tag "speaktomecatalog.com".
  30. Thought A Gremlin on your items ? with 1 viewings related by tag "dev".
  31. Thought some thoughts on trans domain data transfer with 1 viewings related by tag "programming".
  32. Thought about: season's greetings for everyone with 1 viewings related by tag "dev".
  33. Thought a good place to satisfy question~answer with 0 viewings related by tag "programming".
  34. Thought Facebook Ads with 0 viewings related by tag "speaktomecatalog.com".
  35. Thought about: template to start a new coupon with 0 viewings related by tag "speaktomecatalog.com".
  36. Thought Syndicating our products with 0 viewings related by tag "speaktomecatalog.com".
  37. Thought New coupon method request for our catalog ... with 0 viewings related by tag "speaktomecatalog.com".
  38. Thought about: hd radio give away! with 0 viewings related by tag "speaktomecatalog.com".
  39. Thought sources of php code with 0 viewings related by tag "programming".
  40. Thought about: speaktomecatalog.com | facebook with 0 viewings related by tag "speaktomecatalog.com".
  41. Thought Setting Time on the with 0 viewings related by tag "speaktomecatalog.com".
  42. Thought about: amazon.com at a glance: speak_to_me_catalog with 0 viewings related by tag "speaktomecatalog.com".
  43. Thought Black Friday with 0 viewings related by tag "speaktomecatalog.com".
  44. Thought Repeating Quads Structure on tagtalking dev blog with 0 viewings related by tag "dev".
  45. Thought PayPal with 0 viewings related by tag "speaktomecatalog.com".
  46. Thought sql explained for group tagroom with 0 viewings related by tag "programming".
  47. Thought related tags with 0 viewings related by tag "programming".
  48. Thought dynamic cartoons with 0 viewings related by tag "dev".
  49. Thought about: speaktomecatalog.com - web analysis with 0 viewings related by tag "speaktomecatalog.com".
  50. Thought deactivate HTML in comments - or how and where to escape with 0 viewings related by tag "programming".