1 / 19

Database Design 1

Database Design 1. CMS 476 Dr. Karl Horak, Instructor. Session 2.5. Delimiters Logical operators and expressions Demonstration: AND, OR, NOT Exercises. Lecture Topic: Delimiters. Most compilers (and database engines) never allow variables to begin with a digit (or a minus sign).

Télécharger la présentation

Database Design 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Database Design 1 CMS 476 Dr. Karl Horak, Instructor

  2. Session 2.5 • Delimiters • Logical operators and expressions • Demonstration: AND, OR, NOT • Exercises

  3. Lecture Topic:Delimiters • Most compilers (and database engines) never allow variables to begin with a digit (or a minus sign). • Hence, anything starting with a digit is either: • An integer or • Floating point • Things beginning with characters can be all sorts of other stuff

  4. Delimiters • Things with digits or +/- signs are always numeric. • Everything else needs to be characterized for the database engine. • [xyz] in Access indicates that xyz is a field name or a parameter (more on that later) • “xyz” and ‘xyz’ tell the system that xyz is a string of characters • #1/26/53# is how one indicates a date in Access • Otherwise, the database engine divides 1 by 26 by 53 and you get a mess • Actually, 0.0007257 is returned

  5. String Delimiters • ‘Moby Dick’—a string • “Moby Dick”—a string • [Moby Dick]—the Moby Dick(!) field • but “Prisoner’s Dilemma” is needed for an embedded single apostrophe • ‘Prisoner’s Dilemma’ returns an error for unmatched delimiters • [First Name] will indicate a field name, parameter, or variable • Hint: Omit spaces in field names and [ ] are not needed

  6. Dates and Times While we’re talking about dates: • ‘<’ (less than) is “before” • ‘>’ (greater than) is “after” Always remember and don’t ever forget: • Dates are stored as floating point numbers, usually based on the number of days since something like January 1, 1900 • Times are stored as decimal fractions of a day • 6:00 AM is 1/4 of a day, so its 0.25 • Some time functions are accurate to seconds • Other time functions are accurate to milliseconds

  7. Intervals An interval has: • A start time AND • A finish time Example: #1/1/1714# >= Mydate <= #3/26/1837# or (#1/1/1714# >= Mydate) AND (Mydate <= #3/26/1837#)

  8. Lecture Topic:Logical Operators and Expressions • Only two values in Boolean logic: • True & False • Yes & No • On & Off • But then there’s that pesky Null thingie

  9. Boolean Operators • AND—True if both are true • OR—True if either or both are true • NOT—TrueFalse & FalseTrue • XOR—Exclusive OR; true if either one or the other but not both are true

  10. Venn Diagrams p = True p and q q = True AND

  11. NOT p = True Not(p) = True p = False

  12. OR p = True p or q q = True

  13. XOR p = True p xor q p xor q q = True What the heck is this gray area?

  14. Some more examples p = True B? A? D? q = True C? r = True

  15. Null • An unknown value • Not 0 • Neither true nor false • Not an empty string, “” • Not ASCII 0 (or \0) • Not /dev/null • Not a Nil pointer • Frankly, its not anything except Null • Almost any operation or function on Null will return a surprising and often incorrect value • Isnull() tests for Null values when all else fails

  16. Operations on Null • A = Null is neither True nor False • A <> Null is neither True nor False • Null and False = False • Null or True = True

  17. Demonstration • Boolean expressions • Date logic • Complex expressions http://70.56.215.209/khorak/CSF/BooleanExercises.mdb

  18. Exercises and Q&A • List all the inventions created between 1835 and 1845 inclusive along with their inventors. • Which was invented first, the microscope or the thermometer? • Who invented the seed drill? (What the heck is a ‘seed drill’ anyway?) • Did DeGuerre (of DeGuerrotype fame) invent photography? • Claude Bernard is rarely credited with inventing what process with a more famous colleague?

  19. More Exercises • List the names of those in IT who are also in Distribution Group A. • List the names of staff who are characterized as ‘B’. • List all those in ‘C’ or those who did not respond (neither in ‘A’, ‘B’, nor ‘C’). • Who are staff in ‘B’? • Who are in ‘A’ (staff or otherwise? • Who has a ‘K’ or ‘k’ in their name? • Provide a list of persons sorted by first name.

More Related