General Overview Relationship Model Search Trees Searching is an abstract notion that is more abstract than the user of the webpage will actually see when they “search” for things. This abstraction is helpful as it allows the search process to be used internally for various reasons. For example, to view an author’s content, rather than store and retrieve a list of what content the author has created, the search process will be used to populate this list. This abstract notion is solidified using a search tree. A search tree is actually composed of two different types of trees, a data type tree and an expression tree. The data type tree is the “head” of any search tree, and it contains one or more expression trees, so you will see a search tree as an AbstractTypeTree. The data type tree is what defines the type of data is to be returned, that is, whether the search should return content, entities or tags. It contains an expression tree, which defines the properties that the result should have. The expression tree, an AbstractExpressionTree, represents a Boolean expression, of sorts. It can be either simple or complex. A simple expression tree would require only one property, but a complex tree can combine one or more multiple simple expression trees with some Boolean operation. In addition, an expression tree can require relationships with other data type trees. That is, there is another type of expression tree, which is an ExistsExpressionTree. This returns results for which there exists a relationship of a given relationship type (predicate) with another piece of data that fits the results of another data type tree. For example, in the first example of viewing an author’s content through searching. For an author named “Joe Bob”, this would simply be a Content data type tree with it’s expression tree as a exists expression tree with the predicate “author” and an Entity data type tree. This Entity data type tree would have as its expression tree a simple equal-to expression tree with the type “name” and query “Joe Bob”. This tree is very linear, and is diagramed below: One perhaps unintuitive part of this tree is the “Subject” thing written in the ExistsExpressionTree and the EqualToSimpleRExpressionTree. This marks the PartOfSpeech of the nodes, which exists only any node representing a direct query, that is, which contains a single demand for the result. There are only two type of such nodes, at the current time, SimpleExpressionTrees and the ExistsExpressionTree. PartOfSpeech is an enumeration which can only be “Subject” or “Object”. To disguish exactly what the difference is, consider the following examples: The two look identical, except for the “Subject” verses “Object” in the ExistsExpressionTree. The difference is key, however, and tree A represents a search someone who trusts “Joe Bob” while B represents a search for people who are trusted BY “Joe Bob”. Another interesting feature is the “Trust” thing sitting out there under the ExistExpressionTree. This is the Predicate, a struct denoting the predicate of the query. That is, the type of relationship between the top parent EntityTypeTree and the EntityTypeTree under the ExistsExpressionTree. This can be any sort of SearchTypes, such as “author”, “trust”, etc. Some of these SearchTypes can have values, such as trust. To make a query upon the value, the information is stored within the Predicate sturct. To show this, I will expand on the above example A, In this tree, rather than merely searching for someone who has a trust relationship with “Joe Bob”, the query is for someone who trusts “Joe Bob” more than 6. Thus the Predicate can either be simple, and thus query for merely existence, or specific, as query for a value. If specific, there is a comparison type and a numerical value that will be stored in the Predicate. Explanation of Classes Relationship Model Model.AbstractRelationshipModel The abstract structure of a relationship model. A relationship model can be used to model any sort of relationships between various objects in the backend, such as content and entities. Can be used to represent a directed or an undirected graph. Model.RelatedDataModel A concrete implementation of the AbstractRelationshiopModel that models how strongly data is related in an undirected. That it, links between data with various values that represent how similar the pieces of data are. Model.TrustModel A concrete implementation of the AbstractRelationshiopModel that models the trust between entities in a directed graph. That is, links from one entity to another with a value that represents how strongly the first entity trusts the second. Model.RatingModel A concrete implementation of the AbstractRelationshiopModel that models the ratings from entities in a directed graph. That is, links from one entity to another, or to a piece of content, with a value that represents how highly the first entity regards the second object. General Search Search A singleton class that acts as the interface used by the view to perform searches. Also makes the call to the backend to retrieve the search results. SearchParser A singleton class that parses the parameters from the view layer into a search tree that can be used to retrieve results. SearchParameter The parameter the view uses to specify what they want with the query. Includes methods to create search trees from these parameters. Type Tree TypeTree.AbstractTypeTree An abstract class designating what data type of the user is searching for. That is, whether they want people, content, tags, etc. Each type tree has an AbstractExpressionTree child which will select which results of this data type are valid. Can be traversed using an extended visitor. TypeTree.ContentTypeTree A concrete implementation if an AbstractTypeTree that retrieves only content results. TypeTree.EntityTypeTree A concrete implementation if an AbstractTypeTree that retrieves only entity results. TypeTree.TagTypeTree A concrete implementation if an AbstractTypeTree that retrieves only tag results. Expression Tree ExpressionTree.AbstractExpressionTree An abstract class to encompass the entire selection tree in the form of complex boolean expressions, that is, boolean operations upon boolean expressions. Can be traversed using a visitor. ExpressionTree.ExistsExpressionTree A concrete implementation if an AbstractExpresionTree with a Predicate that represents the relationship type and a child AbstractTypeTree. It also holds a PartOfSpeech, a type of enumeration, which tells which “part of speech” the parent type-tree represents. This enumeration is either “Subject” or “Object”. The ExistsExpressionTree connects between types of data. That is, to search for something of one data type, (content, entity, tag), which has some sort of relationship with another data type. It is important to note that the child tree’s data type can be the same as the parent’s, but that the difference lies in searching for something with a relationship to something else that fits certain criteria. That is, an ExistsExpressionTree node is added when the searcher desires for a result which is somehow related to something specific. The relationship type is the type of relationship from the data type of the parent tree to the data type of the child tree. The relationship type can be things such as “trusts” from one entity to another, or “author” from content to an entity. When translating to the quadruple of subjectpredicate-object-value, the parent “variable” is in the position determined by the PartOfSpeech, the predicate and (if it exists) value are stored in the Predicate struct, and the remaining piece is the “variable” of its type tree child. ExpressionTree.AbstractSimpleExpressionTree An abstract implementation of an AbstractExpressionTree encompassing the "simple" selection tree, that is, the specific parameters to search. Represents a Boolean expression for the search process to check in order to select the desired results. It contains a PartOfSpeech, like the Exists tree, which represents where the “variable” of its type tree parent lies. If the PartOfSpeech is Subject, then the query is pertaining to a property of the type tree. If it is Object, then the type tree is the property of the search, that is, something must have it as a property. The simple expression tree has two “fields”, which are the two “missing” parts of speech. To stick with basic English grammar order of subject-predicate-object, the two “fields”, _first and _second, are ordered as such, with the variable PartOfSpeech missing from the link. ExpressionTree.GreaterThanSimpleExpressionTree A concrete implementation of an AbstractSimpleExpressionTree. Here, the boolean expression is "greater than", and as such represents _first > _second. That is to say, represents all results of the given _first that are greater than the given _second. Could be used for things such as dates, rankings, trust, etc. ExpressionTree.LessThanSimpleExpressionTree A concrete implementation of an AbstractSimpleExpressionTree. Here, the boolean expression is "less than", and as such represents _first < _second. That is to say, represents all results of the given _first that are less than the given _second. Could be used for things such as dates, rankings, trust, etc. ExpressionTree.EqualToSimpleExpressionTree A concrete implementation of an AbstractSimpleExpressionTree. Here, the boolean expression is "equal to", and as such represents _first = = _second. That is to say, represents all results of the given _first that are equal to the given _second. Could be used for just about anything from numerical types (dates, ranking, trust, etc.) to string type (keyword, tag, etc.). ExpressionTree.AbstractComplexExpressionTree An abstract implementation of an AbstractExpressionTree that encompasses the "complex" part of the selection tree. Represents boolean operations performed upon simple or complex boolean expressions. That is, ties the boolean expressions together with boolean operations. For now, the AbstractComplexExpressionTree has two children. Specifically, represents a boolean operation between the _leftTree and the _rightTree, where the trees are AbstractExpressionTrees. ExpressionTree.OrComplexExpressionTree A concrete implementation of an AbstractComplexExpressionTree. Here, the boolean operation is "Or" or "or", and as such represents _leftTree || _rightTree. That is to say, represents all results that are in either the _leftTree or the _rightTree, or both. ExpressionTree.AndTwoComplexExpressionTree A concrete implementation of an AbstractComplexExpressionTree. Here, the boolean operation is "And" or "and", and as such represents _leftTree && _rightTree. That is to say, represents all results that are in both the _leftTree and the _rightTree. ExpressionTree.NotComplexExpressionTree A concrete implementation of an AbstractComplexExpressionTree. Here, the boolean operation is "Not" or "not", and as such represents (!_leftTree) && _rightTree. That is to say, represents all results that are in the _rightTree but not in the _leftTree.