Directly Querying the RequisitePro Database (v7.0) DRAFT 1 Introduction This document includes information on how to use SQL to directly query the underlying RequisitePro database. Before proceeding we must emphasize a caveat that the information model in the RequisitePro database is not officially documented although general support on the content and table structures is available from support. As a result, this document represents a “best effort” at reverse engineering of the database structure which may not be complete or totally accurate. The access to this data should strictly be read-only. Under no circumstances should any write operations be done directly to any of these tables. Doing so may cause corruption to the data and perhaps the entire project. Direct write access using SQL to the RequisitePro database is not supported. Obviously, the risk in this approach is that IBM Rational RequisitePro product team retains the right to freely change the underlying database structure in any upcoming release without notification thereby possibly breaking any queries created prior to the release. However, this risk is minimal as the schema has not changed since version 2002.5.20. It will be up to the customer to update their queries in the event of any changes. These examples were developed from a MS Access-based database which only accommodates a single project. The SQL should be similar to DB2, SQL Server, or Oracle, but there will be differences. Furthermore, these queries should not be considered as being optimized. They should be used as examples to work from only and are not intended to be production quality. To make these queries easier to use by more novice SQL users, it is highly recommended that database views be added to the database that simplify some of the joins that are listed in the samples below. Finally, it is highly recommended that you get assistance from your RequisitePro DBA before attempting any of these queries. 2 Essential Tables Not all the tables in the RequisitePro database are needed for querying requirements and related data. Some are used for system support (userids, catalog of views, security etc.). The following tables are the main ones that contain data of interest for querying against requirement text and related attributes. For a detailed list of fields for each of these tables along with comments, simply run the SQL Describe command. 2.1 RqProjects This table contains the list of all projects in the database. 2.2 RqProjectRequirements This table is an intersection table that relates what requirements belong to what projects. 2.3 RqRequirements This table contains all requirements across all projects. This is the table where the requirement name and text (among other fields) are stored. 2.4 RqRequirementTypes This table contains requirement type information across all projects. For example, UC for Use Case, FEAT for Features etc. Page 1 2.5 RqRequirementTypeFields This table is an intersection table used to relate a particular requirement type in a project with its set of user defined attributes. 2.6 RqProjectRequirementTypes This table contains requirement types that exist in particular projects. In other words, each project could have different set of requirement types. 2.7 RqUserDefinedFields This table contains the various user defined attributes for a requirement type across all projects. 2.8 RqUserDefinedFieldValues This table contains actual values for user defined attributes for a requirement type that are just an entry field (not from a drop down list). 2.9 RqUserDefinedListItems This table contains the the various user defined attributes for a requirement type in a project that use a drop down for the valid list of values across all projects. Note this does not contain the actual value for the attribute as related to a specific requirement. It is simply the complete list of valid values for each list for each attribute. 2.10 RqUserDefinedListValues This table contains the selected values by the user from the drop down lists defined in RqUserDefinedListItems table for a given requirement. Note the separate storage of drop down list attributes and values from attributes that are simple text entry fields. Page 2 3 Sample Queries The following sections contain sample queries against tables listed in the prior section. Again, there should be considered as examples to work from and not fully production ready queries. 3.1 List of all projects Includes Project ID (internal), name, prefix (if any), and description SELECT RqProjects.ID, RqProjects.Name, RqProjects.Prefix, RqProjects.Description FROM RqProjects ORDER BY RqProjects.Name; 3.2 List of Attributes of type Drop Down List With Corresponding List of Values This query lists each drop down list attribute with its corresponding list of valid values. Page 3 Result set appears as: Page 4 SQL for this query is: SELECT RqProjects.Name, RqRequirementTypes.RequirementPrefix AS ReqmtTypePrefix, RqUserDefinedFields.Label AS AttributeLabel, RqUserDefinedListItems.ItemRank AS CurrentSortOrder, RqUserDefinedListItems.ItemText AS DropDownListValue FROM (RqUserDefinedFields INNER JOIN RqUserDefinedListItems ON RqUserDefinedFields.ID = RqUserDefinedListItems.FieldID) INNER JOIN ((RqRequirementTypes INNER JOIN (RqProjects INNER JOIN RqProjectRequirementTypes ON RqProjects.ID = RqProjectRequirementTypes.ProjectID) ON RqRequirementTypes.ID = RqProjectRequirementTypes.RequirementTypeID) INNER JOIN RqRequirementTypeFields ON RqRequirementTypes.ID = RqRequirementTypeFields.RequirementTypeID) ON RqUserDefinedFields.ID = RqRequirementTypeFields.UserDefinedFieldID Page 5 ORDER BY RqProjects.Name, RqRequirementTypes.RequirementPrefix, RqUserDefinedFields.Label, RqUserDefinedListItems.ItemRank; Note the sorting. ItemRank is the sort order that RequisitePro uses to display the list of options in the drop down list. This query could be further filtered on just a particular project, requirement type (FEAT), and attribute to just get the list of valid values. That list could be sorted by the value or by the item rank. The following query illustrates this. Note the sort on the value of the drop down list vs Current Sort Order: The SQL for this query is the same as the prior with the exception of the Where clause and the change to the sort. Note this version of the query does specify a particular project using its internal ID number. SELECT RqProjects.Name, RqRequirementTypes.RequirementPrefix AS ReqmtTypePrefix, RqUserDefinedFields.Label AS AttributeLabel, RqUserDefinedListItems.ItemRank AS CurrentSortOrder, RqUserDefinedListItems.ItemText AS DropDownListValue FROM (RqUserDefinedFields INNER JOIN RqUserDefinedListItems ON RqUserDefinedFields.ID = RqUserDefinedListItems.FieldID) INNER JOIN ((RqRequirementTypes INNER JOIN (RqProjects INNER JOIN RqProjectRequirementTypes ON RqProjects.ID = RqProjectRequirementTypes.ProjectID) ON RqRequirementTypes.ID = RqProjectRequirementTypes.RequirementTypeID) INNER JOIN RqRequirementTypeFields ON RqRequirementTypes.ID = RqRequirementTypeFields.RequirementTypeID) ON RqUserDefinedFields.ID = RqRequirementTypeFields.UserDefinedFieldID Page 6 WHERE (((RqProjects.ID)=1) AND ((RqRequirementTypes.RequirementPrefix)="FEAT") AND ((RqUserDefinedFields.Label)="Status")) ORDER BY RqProjects.Name, RqRequirementTypes.RequirementPrefix, RqUserDefinedFields.Label, RqUserDefinedListItems.ItemText; 3.3 List of All Requirements Across All Projects This query lists the project information along with requirements contained in the project along with the requirement type and tag. Note the sort on LongTagNumber which is not displayed. This is so UC3.1 and UC3.10 sort properly. The query is pictorially illustrated below. Page 7 SELECT RqProjects.ID, RqProjects.Name, RqRequirementTypes.Name AS RqmtTypeName, RqRequirements.RequirementPrefix, RqRequirements.RequirementName, RqRequirements.RequirementText FROM RqRequirementTypes INNER JOIN (RqRequirements INNER JOIN (RqProjects INNER JOIN RqProjectRequirements ON RqProjects.ID = RqProjectRequirements.ProjectID) ON RqRequirements.ID = RqProjectRequirements.RequirementID) ON RqRequirementTypes.ID = RqRequirements.RequirementTypeID ORDER BY RqProjects.Name, RqRequirementTypes.Name, RqRequirements.LongTagNumber; Page 8 3.4 List of Certain Requirements Across All Projects This is the same as the query above, but adds a substring search against the requirement text (highlighted) which could be expanded to suit various other query needs. SELECT RqProjects.ID, RqProjects.Name, RqRequirementTypes.Name AS RqmtTypeName, RqRequirements.RequirementPrefix, RqRequirements.RequirementName, RqRequirements.RequirementText FROM RqRequirementTypes INNER JOIN (RqRequirements INNER JOIN (RqProjects INNER JOIN RqProjectRequirements ON RqProjects.ID = RqProjectRequirements.ProjectID) ON RqRequirements.ID = RqProjectRequirements.RequirementID) ON RqRequirementTypes.ID = RqRequirements.RequirementTypeID WHERE (RqRequirements.RequirementText Like "*CDs*") ORDER BY RqProjects.Name, RqRequirementTypes.Name, RqRequirements.LongTagNumber; 3.5 List of All Requirements With Attributes With Data Type of Drop Down Lists This query lists the project name, requirement type, requirement text and corresponding attributes that are of type drop down list. One may add filters to this query (see next query) to include only certain requirements such as only those of a certain type, that contain a string of text in the requirement text as well as have an attribute value of, say “Status” which has a value of “Proposed” as an example. This query just dumps all records to illustrate a starting point. Realistically, this query should not be run across all projects as it will essentially dump the entire database. As a result, this query could have an adverse performance impact on the underlying database. Use this just as an example to work from to add further filtering to reduce the amount of data. A pictorial illustration of the query follows the SQL. Page 9 SELECT RqProjects.Name, RqRequirementTypes.RequirementPrefix AS ReqmtTypePrefix, RqRequirements.RequirementPrefix AS ReqmtTypeFullTag, RqRequirements.RequirementText, RqUserDefinedFields.Label AS Attribute_List_Label, RqUserDefinedListItems.ItemText AS Attribute_List_Value Page 10 FROM RqUserDefinedListItems INNER JOIN (RqUserDefinedFields INNER JOIN (RqRequirementTypes INNER JOIN ((RqRequirements INNER JOIN (RqProjects INNER JOIN RqProjectRequirements ON RqProjects.ID = RqProjectRequirements.ProjectID) ON RqRequirements.ID = RqProjectRequirements.RequirementID) INNER JOIN RqUserDefinedListValues ON RqRequirements.ID = RqUserDefinedListValues.RequirementID) ON RqRequirementTypes.ID = RqRequirements.RequirementTypeID) ON RqUserDefinedFields.ID = RqUserDefinedListValues.FieldID) ON RqUserDefinedListItems.ItemID = RqUserDefinedListValues.ListItemID ORDER BY RqProjects.Name, RqRequirementTypes.RequirementPrefix, RqRequirements.LongTagNumber, RqRequirements.RequirementPrefix, RqUserDefinedFields.Label; The query results would look like the following (note that not all attributes for each requirement are listed. Only that attributes that have values are listed.): Page 11 3.6 List of All Requirements With Attributes With Data Type of Drop Down Lists - Filtered This query is the same as the prior query but includes filters on UC requirement types across all projects where the attribute Property (which is a drop down list item) has the value “Basic Flow”. This list results in just the basic flow text across all use cases across all projects. Note this does not include attributes that are not drop down lists. SELECT RqProjects.Name, RqRequirementTypes.RequirementPrefix AS ReqmtTypePrefix, RqRequirements.RequirementPrefix AS ReqmtTypeFullTag, RqRequirements.RequirementText, RqUserDefinedFields.Label AS Attribute_List_Label, RqUserDefinedListItems.ItemText AS Attribute_List_Value FROM RqUserDefinedListItems INNER JOIN (RqUserDefinedFields INNER JOIN (RqRequirementTypes INNER JOIN ((RqRequirements INNER JOIN (RqProjects INNER JOIN RqProjectRequirements ON RqProjects.ID = RqProjectRequirements.ProjectID) ON RqRequirements.ID = RqProjectRequirements.RequirementID) INNER JOIN RqUserDefinedListValues ON RqRequirements.ID = RqUserDefinedListValues.RequirementID) ON RqRequirementTypes.ID = RqRequirements.RequirementTypeID) ON RqUserDefinedFields.ID = RqUserDefinedListValues.FieldID) ON RqUserDefinedListItems.ItemID = RqUserDefinedListValues.ListItemID WHERE (((RqRequirementTypes.RequirementPrefix)="UC") AND ((RqUserDefinedFields.Label)="Property") AND ((RqUserDefinedListItems.ItemText)="Basic Flow")) ORDER BY RqProjects.Name, RqRequirementTypes.RequirementPrefix, RqRequirements.LongTagNumber; The result set would look like the following: Page 12 Here is the same query, but with a substring search against the requirement text field added to the filtering. This query selects all use case requirements where the requirement text contains the string “Warehouse System” and the Property attribute value of the requirement is “Basic Flow”. SELECT RqProjects.Name, RqRequirementTypes.RequirementPrefix AS ReqmtTypePrefix, RqRequirements.RequirementPrefix AS ReqmtTypeFullTag, RqRequirements.RequirementText, RqUserDefinedFields.Label AS Attribute_List_Label, RqUserDefinedListItems.ItemText AS Attribute_List_Value FROM RqUserDefinedListItems INNER JOIN (RqUserDefinedFields INNER JOIN (RqRequirementTypes INNER JOIN ((RqRequirements INNER JOIN (RqProjects INNER JOIN RqProjectRequirements ON RqProjects.ID = RqProjectRequirements.ProjectID) ON RqRequirements.ID = RqProjectRequirements.RequirementID) INNER JOIN RqUserDefinedListValues ON RqRequirements.ID = RqUserDefinedListValues.RequirementID) ON RqRequirementTypes.ID = RqRequirements.RequirementTypeID) ON RqUserDefinedFields.ID = RqUserDefinedListValues.FieldID) ON RqUserDefinedListItems.ItemID = RqUserDefinedListValues.ListItemID Page 13 WHERE (((RqRequirementTypes.RequirementPrefix)="UC") AND ((RqRequirements.RequirementText) Like "*Warehouse System*") AND ((RqUserDefinedFields.Label)="Property") AND ((RqUserDefinedListItems.ItemText)="Basic Flow")) ORDER BY RqProjects.Name, RqRequirementTypes.RequirementPrefix, RqRequirements.LongTagNumber; The result set would look like the following: 3.7 List of All Requirements With Attributes of Data Type Text (or Numeric) This query displays all requirements that have text or numeric attribute types. Page 14 SELECT RqProjects.Name, RqRequirementTypes.RequirementPrefix AS ReqmtTypePrefix, RqRequirements.RequirementPrefix AS ReqmtTypeFullTag, RqRequirements.RequirementText, RqUserDefinedFields.Label AS Attribute_Text_Label, RqUserDefinedFieldValues.FieldValue AS Attribute_Text_Value, RqUserDefinedFieldValues.NumericValue FROM RqUserDefinedFields INNER JOIN ((RqRequirementTypes INNER JOIN (RqRequirements INNER JOIN (RqProjects INNER JOIN RqProjectRequirements ON RqProjects.ID = RqProjectRequirements.ProjectID) ON RqRequirements.ID = RqProjectRequirements.RequirementID) ON RqRequirementTypes.ID = Page 15 RqRequirements.RequirementTypeID) INNER JOIN RqUserDefinedFieldValues ON RqRequirements.ID = RqUserDefinedFieldValues.RequirementID) ON RqUserDefinedFields.ID = RqUserDefinedFieldValues.FieldID ORDER BY RqProjects.Name, RqRequirementTypes.RequirementPrefix, RqRequirements.LongTagNumber; The result set looks like the following: 3.8 Combined View of Attributes With Data Types of Both Text and Drop Down List At this point, one might note that attributes of type text and drop down list are stored in different underlying table structures. The queries up to this point have dealt with these in separate queries. The next logical step would be to develop a query that combines all attributes together regardless of type. Since this involves some rather complex table joins, possibly using a UNION SQL operator (the syntax of which may be different in the various databases), this exercise is left to the customer to develop using their specific database vendor’s SQL. Page 16
© Copyright 2026 Paperzz