Mdst3705 2013-02-05-databases


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • (theoretically)
  • Let’s look at another tree
  • Let’s look at another tree
  • Mdst3705 2013-02-05-databases

    1. 1. From Data Structures to Databases Prof. Alvarado MDST 3703 5 February 2013
    2. 2. Business• Quiz 1 – To be posted this evening – Due Thursday evening – Covers content before Databases – End-of-week reflections still due• Blogging – Please remember to be timely• Safari Resources – If you can‟t access, try going through the Library page
    3. 3. Review• Building as knowing – Ramsay‟s point in “On Building”• DH as cultural reverse engineering – Finding the rules in the patterns – Texts and images are the patterns in question• Reverse engineering is like building – Same process in reverse (deconstruction) – Also requires building other things – like databases to store stuff
    4. 4. For example, in Studio on Thursday we began to reverseengineer Plato’s Republic. The next step in our exercisewas to parse the text into “words” and organize them in alist using an array
    5. 5. By the way, were we actually grabbing words?
    6. 6. Not really – we were find substrings, letter patterns that could also exist within words (e.g. “cavern”) Also, these patterns did not matchsynonyms or pronouns (e.g. “this”) thatstand for the same thing as the word in questionThis is the difference between SYNTAX and SEMANTICS
    7. 7. Syntax = sequences of signs Semantics = meanings of signsSemantics is much harder for computers to grasp than syntax In fact, some think that semantics isbeyond the capacity of any computer …
    8. 8. Getting back to PHPWe can use arrays to model the text. So,within a FOREACH loop iterating throughthe lines of a text and parsing each line for“words,” we could do the following: $words[$word]++; $words[] = $word; $lines[$lineNumber][] = $word;Each method suggests a different model
    9. 9. More about PHP Arrays• Arrays can be added to like so: $myArray[] = $newItem;• Arrays can also use strings instead of number as indices, e.g. $myArray[3] = „foo‟; $myArray[„person‟] = „Bob‟;• Array items may also point to arrays, creating multidimensional arrays $myArray[„person‟] = array(); $myArray[„person‟][„Bob‟] = $something;
    10. 10. Arrays with string indices are called “associative arrays” in PHPArrays of arrays can be used to create data structures like trees and grids
    11. 11. Read Chapter 5 of PHP: TheGood Parts to learn moreabout arrays (see link inResources on the course blog)Also, the PHP manual is alwaysa good place to look
    12. 12. Arrays as Data Structures• PHP arrays can be used to create data structures to model things, like texts, e.g. $words[$word]++; $words[] = $word; $lines[$lineNumber][] = $word;• These three create the following 1. A simple list of word types (and their counts) 2. A list of each word in order (position and word) 3. A grid of line numbers and words
    13. 13. Here is an example of how we would createthe third kind of data structure. This wouldstore a grid of words.
    14. 14. These numbers are the first dimension of the array (Y) These horizontal numbers are the second dimension of the array (Y)And it would store the text in grid somethinglike this one …
    15. 15. In this model, a text is a grid of words, each with an X and Y coordinateIs this the only way to represent a text? Is it the most accurate?
    16. 16. Texts can also be represented as trees
    17. 17. Document Elements and StructuresPlay – Heading – Act + • Return Address • Scene + • Date – Line + • Recipient Info – NameBook – Title – Chapter + – Address • Verse + – Content • Salutation • Paragraph + • ClosingLetter
    18. 18. XML is designed to represent text
    19. 19. What are some differences between trees and tables?
    20. 20. Tables are more rigid Trees allow for indefinite depth But tables are easier to manipulateIn any case, tables and trees are twomajor kinds of data structure that you will encounter …
    21. 21. Speaking of trees …what is this?
    22. 22. Tree of Logic (and a primitive computer)". . . the tree of nature and logic by thethirteenth-century poet, philosopher, andmissionary Ramon Lull. The main trunk supportsa version of the tree of Porphyry, whichillustrates Aristotles categories. The ten leaveson the right represent ten types of questions,and the ten leaves on the left are keyed to asystem of rotating disks for generating answers.Such diagrams and disks comprise Lulls ArsMagna (Great Art), which was the first attemptto develop mechanical aids to reasoning. Itserved as an inspiration to the pioneer insymbolic logic, Gottfried Wilhelm Leibniz.”John Sowa, explaining the cover art forKnowledge Representation
    23. 23. What is this tree an example of?
    24. 24. The tree is a “knowledge representation” (KR)
    25. 25. A KR is a model that comprises1. A set of categories (aka Ontology) Names and relationships between names2. A set of inference rules (aka Logic) A method of traversing names and relations3. A medium for computation A medium for producing inferences4. A language for expressing these things Such as a programming or markup language
    26. 26. Ontologies are systems ofcategories rooted in worldviews
    27. 27. Ontologies consist ofcategories and theirrelationshipsThese are often mappedonto physical things – thehuman body, or trees – aspart of our cognitive model
    28. 28. The tree as body as society among the Umeda of New Guinea
    29. 29. Logic is a name for the systematicunpacking ontologies in discourse …
    30. 30. Here is a sampleontology, onevery similar toAristotle’s
    31. 31. And this is a syllogism, the basic unit ofreasoning in classical logic How is it related to the tree?
    32. 32. The sentences in thesyllogism stand forthe traversal of thetree that representsan implicit ontology
    33. 33. Reasoning always implies an ontology Ontologies are often unexpressedOntologies often conflict with each other(Digital) Humanists excavate or reverse engineer these ontologies
    34. 34. Now, a KR for a computer has to be an operationalized KRHow would we express a syllogism in PHP?
    35. 35. One way is to convertthe tree into an array
    36. 36. But, given such an array, how can we find out if Socrates is mortal? How do we find if the following is set:0 1 2 3 4
    37. 37. We’d have to some some complicated nested looping tofind the answer …
    38. 38. So, PHP gives us tools to create an ontology, but not a way to reason efficiently with themTo create more effective KRs, we need the services of a database
    39. 39. A database is a “a system that allows for the efficient storage and retrieval of information” But beyond this, it also allows us to “represent knowledge”Given Unsworth‟s definition, how must it do this?
    40. 40. Databases provide a language to define ontologies (schema) and to “unpack”these ontologies – via a query language that lets us efficiently search and retrieve data organized schema
    41. 41. In this course, we are going to use arelational database to store and access information Relational databases use a language known as SQL(pronounced S-Q-L, although some say “sequel”)
    42. 42. SQL• SQL stands for “Structured Query Language” – NOT invented by Microsoft• Invented in the 1970s and commercialized in the 1980s – Probably responsible for new business models like JIT inventories• Built on Codd‟s relational model (1970) – Implements set theory and formal logic – Around the time of SGML
    43. 43. SQL• A language used by relational databases – Oracle, SQL Server, Access, etc.
    44. 44. MySQL• A very fast, simplified, and easy to use relational database• A client/server app – Runs on the internet – Not a desktop app like Access• Created by Monty Widenius in the mid 1990s – Open Source – A Finn living in Sweden – Same time as PHP• Powered the Web 2.0 revolution
    45. 45. phpMyAdmin• A PHP interface to MySQL• Relatively easy to use – No need to know SQL• Great to manage databases that your PHP programs will use• Today you will get started using UVA‟s free MySQL server
    46. 46. The role of PHP