This tutorial guides you through the major tasks of creating a Microsoft English Query application, using the sample database Pubs. To print the tutorial in its entirety, click Print or, from the File menu, click Print Topic.
Before you start Make sure you have access to the Pubs database, and start English Query. (If you need help connecting to Pubs, ask your system administrator.) This tutorial takes about an hour to complete. If you want to stop the tutorial and come back to it later, you can save the project. For information about saving the project, see Saving the Pubs Project section later in this tutorial.
The sample Pubs database is installed with Microsoft® SQL Server™. This database might be used for a large publishing concern that needs to track authors, titles, stores, and its smaller publishing groups. An English Query application based on this database could provide people with the ability to ask publishing-related questions, such as which employees work in which publishing groups, or which author has written a specific book.
An overview of the tables, fields, and joins in this database follows:
The Sample Database
The following illustration shows some of the many entities and relationships (semantic objects) possible with the Pubs database. In this tutorial, you’ll be creating a few of these.
Entities and Relationships (The highlighted entities are defined in this tutorial.)
Consider the questions that users of a Pubs English Query application might want to ask. In particular, look at questions that concern the entities author and book. Looking at a few potential questions will help you create the entities and relationships (expressed as phrasings) in the following steps.
Questions about authors and books | Relationship phrasings needed |
---|---|
List all the authors. | Author entity (no phrasings needed). |
Show the authors and their phone numbers | Authors have phone numbers. (Trait phrasing.) |
Which author wrote Net Etiquette? or, Who wrote Net Etiquette? | Titles are the names of books. (Name phrasing.) Authors write books. (Verb phrasing.) |
Which books are written by Albert Ringer? | Authors have names. (Name phrasing.) Authors write books. (Verb phrasing.) |
As you may have guessed, there are many ways in which questions can be phrased by the user. A corresponding relationship phrase is needed for each type of question.
First, you will retrieve the structure of the Pubs database and open it in the English Query domain editor. The structure of the database is part of the domain knowledge needed to build an English Query application, and it allows you to associate entities with tables and fields in the database.
To extract the structure of the Pubs database
(You may need to create a new ODBC data source first. Click Help for information about creating a new data source.)
For example, both Login ID and Password might accept the entry guest. (Contact your system administrator if you need help logging on.) Click OK.
Notice that table names are preceded by a designator for the owner of the table (in this case, dbo for database owner). In this tutorial, table names are referred to without the owner designation, for example, authors.
To make sure the project works properly, you must:
Keys are fields used to identify records.
To assign keys
You can also select these fields from a list by clicking Specify Keys.
You can save your version of the Pubs project as you work, especially if you need to delay completion of the tutorial. Because Pubs.eqp is shipped as a sample file, you’ll want to give your version a unique name: for example, Mypubs.eqp.
To save the project
In this tutorial, you will define two entities and then create the relationship between them. Then you'll move on to defining subsequent entities and their relationships. In the future, you may want to define all the entities of your own application and then go back to define all the relationships. However, the first method is recommended for learning how to use English Query.
First you’re going to define the major entity book, followed by the creation of the entity title, and then a relationship between book and title.
Creating the Book Entity
You define the book entity to answer general questions about the titles in the Pubs database, such as, “How many books are there?” or, “List the books.” The book entity is represented by the entire Titles table.
To create the book entity
This option indicates that each row in the Titles table uniquely identifies a book. For example, you want to allow a question such as, “Count the books.” Associating the book entity with the entire Titles table, rather than just the title field, ensures that the count is correct. Because all fields are used in the count to uniquely identify the book, two books that happen to have the same title are counted individually.
Creating the Title Entity and Relationship with Book
The title entity is a minor entity. You define a title entity to answer specific questions about the books in the Pubs database, such as, “What book starts with the word Net?” The title entity is represented by the Title field in the Titles table.
To create the title entity
Because the title entity is represented by a field in the Titles table, you now must specify some database properties as well.
To create the relationship titles are names of books
Next you’ll create the major entity author, followed by its trait entities, which include author_name, author_address, and author_phone. You’ll define the relationships between these entities and author as you create each of them.
Each relationship, separately and used together with others, tells English Query how to answer the following types of questions:
Questions | Entities needed | Phrasings used to create relationships |
What are the names of all the authors? | Author | author_names are the names of authors |
What is Bennet’s first name? | Author author_names |
author_names are the names of authors |
List the authors and their phone numbers. | Author author_phone |
authors have author_phones |
What is Sheryl Hunter’s phone number? | Author author_phone |
author_names are the names of authors authors have author_phones |
What are the addresses of all the authors? | Author author_address |
authors have author_addresses |
What is Michael O’Leary’s address? | author author_names author_address |
author_names are the names of authors authors have author_addresses |
Creating the Author Entity
The author entity is a major entity. You define an author entity to answer general questions about the authors in the Pubs database, such as, “How many authors are there?” or “List the authors.” The author entity is represented by the entire Authors table.
To create the author entity
This option indicates that each row in the Authors table uniquely identifies an author. For example, you want to allow a request such as “Count the authors.” Associating the author entity with the entire Authors table, rather than just the author name fields, ensures that the count is correct. Because all fields are used in the count to uniquely identify the author, two authors that happen to have the same name are counted individually.
You enter these fields so that the authors’ names and phone numbers will display whenever general questions about authors are asked. For the questions, “What authors live in Ann Arbor?” and “List all of the authors,” you see answers that include the authors’ names and phone numbers.
Creating the Author_Name Entity and Relationship
You’re going to create an author_name entity so that users of this application can ask questions about specific authors. For example, “What do you know about Charlene Locksley?” Creating an author_name entity and its relationship with author tells English Query that proper nouns (which are initial-capped) correspond to values stored in the Authors table.
To create the author_name entity and relationship using Autoname
To see the objects created using Autoname, look on the Semantic Objects tab. The author name minor entity appears under the author entity. The author_names_are_the_names_of_authors relationship appears under Relationships.
Now create the author_address entity and the relationship between it and author: authors have addresses. This phrasing makes possible questions about author addresses, such as, “List all the authors and their addresses.”
Creating the Author_Address Entity and Relationship
You’re going to create the author_address entity so that users can ask questions such as, “What is Albert Ringer’s address?”
To create the author_address entity
To create the relationship authors have addresses
Creating the Author_Phone Entity
When used with the author entity in a relationship, the author_phone entity allows English Query to answer questions about an author’s phone number, such as, “List the authors and their phone numbers.” Along with the relationship between author_name and author, the author_phone entity and its relationship with author also answers questions about specific authors, such as, “What is Anne Ringer’s phone number?”
To create the author_phone entity
The data from these fields will now be used to answer questions about authors’ phone numbers.
To create the relationship authors have author_phones
Creating the Store Entity and Relationship with Book
You can define a store entity to answer specific questions about what books the book stores buy. The store entity is represented by the Stores table.
To create the store entity
To create the relationship stores buy books
Note It’s a good idea to save your project now. For information, see Saving the Pubs Project, earlier in this topic.
It’s important to test the preceding questions to make sure the new relationships between entities work as expected. You may have to log into the Pubs database again.
To test the Author Questions
The question is restated in the Restatement box.
To see the returned answers, click Execute SQL.
To see the phrasings used to answer this question, click Analysis.
Using this process, try out these other test questions:
“What is Bennet’s first name?”
“List all the phone numbers.”
“What is Sheryl Hunter’s phone number?”
“Where do the authors live?”
“What is Michael O'Leary address?”
Defining a relationship between the major entity author and the major entity book tells English Query how to answer the following types of questions:
Questions | Entities needed | Phrasings used to create relationships |
What authors wrote what books? | author book |
authors write books (Verb phrasing) |
List the books by Anne Ringer. | author author_name book |
author_names are the names of authors (Name phrasing) books are by authors (Verb phrasing) |
What books are written by Anne Ringer? | author author_name book |
author_names are the names of authors (Name phrasing) authors write books (Verb phrasing) |
When creating relationships with verb phrases, phrase them in active voice, such as, authors write books, instead of the passive voice, such as, books are written by authors. When you specify relationships in active voice, users can ask questions in either active or passive voice (in other words, you get passive voice automatically).
The following steps help you define the phrasings needed to answer these questions, such as authors write books (which also covers the passive, books are written by authors) and a simpler prepositional phrasing, books are by authors.
To create the relationship authors write books
Note When creating relationship phrasings, entities are shown in the plural: authors and books. This so you will naturally type the base form, or root, of the verb—write, in this case (authors write books), rather than the writes as in the incorrect authors writes books.
Now create another phrasing to express this relationship: books are by authors.
Now you're going to test questions to make sure the new entities and relationships return the answers you expect.
To test author writes books questions
The question is restated in the Restatement box.
To see the returned answers, click Execute SQL.
To see the phrasings used to answer this question, click Analysis.
Using this process, try out the other questions such as:
“List the books by Anne Ringer.”
“What books are written by Anne Ringer?”
“How many books did Marjorie Green write?”
“Did Michael O’Leary write a book?”
Try asking related questions such as, “List the authors and books.” Notice that there are two answers: a list of authors and a list of books, but no association between them. To get the right association, you’d have to ask a slightly different question, one that uses a relationship between authors and books, such as, “List the authors and their books” (authors write books phrasing), or “List the books written by authors” (books are written by authors phrasing).
Here you use the Suggestion feature to help you test questions.
To test a question about stores
The answer is now provided.
When you build the Pubs English Query application, the file created for this application uses the name of the project: in this case, Mypubs.eqd.
To build the Mypubs application
A message warns you that build time depends on the number of data values loaded into the English Query dictionary. In this case, the build time will be brief.
When the build has completed, a confirmation box shows the path for the application. Its name is Mypubs.eqd.
You can deploy English Query applications in several ways: by deploying on the Web and by embedding English Query functionality in a Microsoft Visual Basic® or Microsoft Visual C++® application.
If you’re running Internet Information Server 4.0 and IIS with the Windows Scripting Host installed, the simple way to deploy a Web page that allows users to pose questions to your English Query domain is to run Setupasp.vbs. It is in the \Program Files\Microsoft English Query\Samples\Asp2 directory.
Setupasp.vbs is a Windows Scripting Host (WSH) script that copies the ASP files and the domain file (.eqd) to a directory on the Web server, creates an IIS virtual directory for the English Query pages, and sets options in a file called Params.inc, which indicates to the ASP script where to find your database. Then you can test your application and link to the page from other Web pages on your site, including other ASP applications.
For more information on embedding an English Query applications in your own ASP applications, see Overview of Deploying on the Web.