You are here: Learn > The Library > Daily News Desk > Ancestry Daily News

Ancestry Daily News
1/19/1999 - Archive

•  Protect Your Keepsakes—Part 2: Paper
•  The Basics of Boolean Logic for the Genealogist

The Basics of Boolean Logic for the Genealogist

Using search engines and searching online databases presents the genealogist with access to previously untold amounts of data. However, searching an online database is significantly different from searching a printed index. One technique for allowing the user to perform more sophisticated searches is the use of Boolean logic. Although this may sound complicated, you don't need to be a math professor to understand the basics of Boolean logic.

And and Or
a) I went to the library and did not go to the courthouse
b) I went to the courthouse and did not go to the library
c) I went to the library and to the courthouse

The only time this statement would not be true would be when I did not go to the library and did not go to the courthouse. So the inclusive or includes, but is not limited to, the statement where and is used as the connector.

There are many online databases that allow the user the option of searching with the word "or," or with the word "and" between the terms or phrases to be located. A search for those pages that contain the word "jones" or the word "henry," will return those pages that contain "jones" only, contain "henry" only, and those that contain both "jones" and "henry" (similarly to when the statement "I'm going to the library or the courthouse would be true using the inclusive or). A search for "jones and henry" will return only those pages that contain both "henry" and "jones." An "and" search is more restrictive than an "or" search. While it is theoretically possible for an "and" search and an "or" search to result in the same number of results, practically speaking, an "or" search will result in more hits.

Another way to think of these connectors is to imagine the "located" pages being put into a pot. An "or" connector will put a located page in the pot if it contains at least one of the desired search terms. An "and" connector will only put those pages in the pot that contain all the desired search terms. Readers who see a connection between these terms and the concepts of union and intersection involving sets are exactly correct. See math does have use for genealogists!

The Use of Parentheses
Ordering your search is very important. In some search interfaces, there is the option of including parenthesis in your searches. These parentheses are not to add parenthetical comments to your search. They provide the user with a greater sophistication in their searches and allow an ordering of the search to take place. Readers who never understood parenthesis in algebra, take note. Our examples will discuss searching for Web pages, however, searches of library card catalogs and other databases are similar in terms of the logical connectives.

Consider the search "red or blue and green." As this search is written, it will be performed from left to right. The first operation to be performed will be the "red or blue" part. If the search was looking for Web pages, it would locate those pages that contained either the word "red" or the word "blue." The pages would not have to contain both words. These pages could, again, be put in a big pot. This pot of pages would then be "anded" with "green." The resulting set of pages would include any page from the first pot as long as it also contained the word "green." A little thought should lead to the conclusion that the search for "red or blue and green" will include those pages that contain "red and green" in addition to those pages that contain "blue and green." (Readers with a mathematical bent will recognize this as an application of one of De Morgan's Laws.)

The previous search is equivalent to the search "(red or blue) and green." In this case, the parentheses are not technically necessary, as the first operation would be done anyway. However, always including parenthesis is not wrong and may assist the user in formulating searches.

However, moving the parenthesis results in a different search. Consider the search "red or (blue and green)." In this example, the first part of the search conducted is the "blue and green" portion. Those pages that contain both the words blue and green will be obtained. Then the "or" part of the search will be conducted. This will have the effect of simply adding all those pages containing the word "red" to the set that has already been obtained. This may seem confusing.

And on one hand it is. In this example, the "or" adds pages. The reader must not confuse the word "add" with the word "and." In the sense of numbers, "and" and "add" serve a similar purpose (3 and 4 is generally considered the same as 3 added to 4). However, in the type of searches we are discussing, we are not adding numbers. We are combining sets of pages and in this context "add" and "and" are interpreted slightly differently.

Another Example
The Search (red or blue) and (green or brown)

For purposes of understanding, it may be easiest to consider this search as taking place in three steps.

  • Step One - red or blue
    This search will locate those pages that contain the word red or the word blue. Remember that a page may contain both these words and the words may not be located near each other.

  • Step Two - green or brown
    This search will locate those pages that contain the word green or the word brown. Again, the page may contain both words and the words may not be located near each other.

  • Step Three - Results of Step 1 "anded" with Step 2
    This search will locate those pages that were located in both steps one and two.

    This search would locate the following pages:

    red and green
    red and brown
    blue and green
    blue and brown
    red, blue and brown
    red, blue, and green
    red, green, and brown
    blue, green, and brown
    red, blue, green, and brown

    Pages containing only one of the four colors would not be located, nor would pages containing just red and blue and pages containing just green and brown.

    The Search: Red or (Blue and Green) or Brown
    The parentheses in this search have been moved from the previous search. We could think of this search as being conducted in four steps.

    Step 1-locate pages containing red
    Step 2-locate pages containing blue and green
    Step 3-locate pages containing brown
    Step 4-since the results of step 1, 2, and 3 are all connected by ors, any page that is located at least once will be found in the final result.

    It should be noted in the final result of this search if a located page contains blue it must also contain green (due to the middle portion of the search being contained in parenthesis and containing the word "and"). Pages containing the following will be located:

    red only
    brown only
    blue and green
    red and brown
    red, blue, and green
    brown, blue, and green

    Searches containing only "and" or searches containing only "or" can be performed without the use of parenthesis. Some searches that combine the two can be conducted with or without parenthesis, but not all. For this reason, it is generally a good idea to include parenthesis on any searches that use both "and" and "or."

    Good Luck!

    Michael John Neill, is the Course I Coordinator at the Genealogical Institute of Mid America (GIMA) held annually in Springfield, Illinois, and is also on the faculty of Carl Sandburg College in Galesburg, Illinois. Michael is the education columnist for the FGS FORUM and is on the editorial board of the Illinois State Genealogical Society Quarterly. He conducts seminars and lectures on a wide variety of genealogical and computer topics and contributes to several genealogical publications, including Ancestry and Genealogical Computing.


  •   Printer Friendly
     
    E-mail to a friend

    Search The Library



    Weekly Journal

    Sign up for the Ancestry Weekly Discovery and get free family history tips, news and updates in your inbox.