Grammatical relation
In linguistics, grammatical relations (also called grammatical functions, grammatical roles, or syntactic functions) are functional relationships between constituents in a clause. The standard examples of grammatical functions from traditional grammar are subject, direct object, and indirect object. In recent times, the syntactic functions (more generally referred to as grammatical relations), typified by the traditional categories of subject and object, have assumed an important role in linguistic theorizing, within a variety of approaches ranging from generative grammar to functional and cognitive theories. Many modern theories of grammar are likely to acknowledge numerous further types of grammatical relations (e.g. complement , specifier, predicative, etc.). The role of grammatical relations in theories of grammar is greatest in dependency grammars, which tend to posit dozens of distinct grammatical relations. Every head-dependent dependency bears a grammatical function. Grammatical categories are assigned to the words and phrases that have the relations. This includes traditional parts of speech like nouns, verbs, adjectives, etc., and features like number and tense. In traditional grammar. The grammatical relations are exemplified in traditional grammar by the notions of subject, direct object, and indirect object: The subject "Fred" performs or is the source of the action. The direct object "the  book" is acted upon by the subject, and the indirect object Susan receives the direct object or otherwise benefits from the action. Traditional grammars often begin with these rather vague notions of the grammatical functions. When one begins to examine the distinctions more closely, it quickly becomes clear that these basic definitions do not provide much more than a loose orientation point. What is indisputable about the grammatical relations is that they are relational. That is, subject and object can exist as such only by virtue of the context in which they appear. A noun such as "Fred" or a  noun phrase such as "the book" cannot qualify as subject and direct object, respectively, unless they appear in an environment, e.g. a clause, where they are related to each other and/or to an action or state. In this regard, the main verb in a clause is responsible for assigning grammatical relations to the clause "participants". Defining the grammatical relations. Most grammarians and students of language intuitively know in most cases what the subject and object in a given clause are. But when one attempts to produce theoretically satisfying definitions of these notions, the results are usually less than clear  and therefore controversial. The contradictory impulses have resulted in a situation where most theories of grammar acknowledge the grammatical relations and rely on them heavily for describing phenomena of grammar but at the same time, avoid providing concrete definitions of them. Nevertheless, various principles can be acknowledged that attempts to define the grammatical relations are based on. Thematic criteria. The thematic relations (also known as thematic roles, and semantic roles, e.g. agent, patient, theme, goal) can provide semantic orientation for defining the grammatical relations. There is a tendency for subjects to be agents and objects to be patients or themes . However, the thematic relations cannot be substituted for the grammatical relations, nor vice versa. This point is evident with the active-passive diathesis and ergative verbs: "Marge" is the agent in the first pair of sentences because she initiates and carries out the action of fixing, and "the coffee table" is the patient in both because it is acted upon in both sentences. In contrast, the subject and direct object are not consistent across the two sentences. The subject is the agent "Marge" in the first sentence and the patient "The coffee table" in the second sentence. The direct  object is the patient "the coffee table" in the first sentence, and there is no direct object in the second sentence. The situation is similar with the ergative verb "sunk/sink" in the second pair of sentences. The noun phrase "the ship" is the theme in both sentences, although it is the object in the first of the two and the subject in the second. The grammatical relations belong to the level of surface syntax, whereas the thematic relations reside on a deeper semantic level. If, however, the correspondences across these levels are acknowledged, then the thematic relations can be  seen as providing prototypical thematic traits for defining the grammatical relations. Configurational criteria. Another prominent means used to define the syntactic relations is in terms of the syntactic configuration. The subject is defined as the verb argument that appears outside of the canonical finite verb phrase, whereas the object is taken to be the verb argument that appears inside the verb phrase. This approach takes the configuration as primitive, whereby the grammatical relations are then derived from the configuration. This "configurational" understanding of the grammatical relations is associated with Chomskyan phrase structure grammars (Transformational grammar, Government and Binding and Minimalism ). The configurational approach is limited in what it can accomplish. It works best for the subject and object arguments. For other clause participants (e.g. attributes and modifiers of various sorts, prepositional arguments, etc.), it is less insightful, since it is often not clear how one might define these additional syntactic functions in terms of the configuration. Furthermore, even concerning the subject and object, it can run into difficulties, e.g. The configurational approach has difficulty with such cases. The plural verb "were" agrees with the post-verb noun phrase "two lizards", which suggests that "two lizards" is the subject. But since  two lizards follows the verb, one might view it as being located inside the verb phrase, which means it should count as the object. This second observation suggests that the expletive "there" should be granted subject status. Morphological criteria. Many efforts to define the grammatical relations emphasize the role inflectional morphology. In English, the subject can or must agree with the finite verb in person and number, and in languages that have morphological case, the subject and object (and other verb arguments) are identified in terms of the case markers that they bear (e.g. nominative, accusative, dative, genitive, ergative, absolutive , etc.). Inflectional morphology may be a more reliable means for defining the grammatical relations than the configuration, but its utility can be very limited in many cases. For instance, inflectional morphology is not going to help in languages that lack inflectional morphology almost entirely such as Mandarin, and even with English, inflectional morphology does not help much, since English largely lacks morphological case. Prototypical traits. The difficulties facing attempts to define the grammatical relations in terms of thematic or configurational or morphological criteria can be overcome by an approach that posits prototypical traits. The prototypical subject has a cluster of  thematic, configurational, and/or morphological traits, and the same is true of the prototypical object and other verb arguments. Across languages and across constructions within a language, there can be many cases where a given subject argument may not be a prototypical subject, but it has enough subject-like traits to be granted subject status. Similarly, a given object argument may not be prototypical in one way or another, but if it has enough object-like traits, then it can nevertheless receive the status of object. This third strategy is tacitly preferred by most work in theoretical syntax. All those theories  of syntax that avoid providing concrete definitions of the grammatical relations but yet reference them often are (perhaps unknowingly) pursuing an approach in terms of prototypical traits. Heads and dependents. In dependency grammar (DG) theories of syntax, every head-dependent dependency bears a syntactic function. The result is that an inventory consisting of dozens of distinct syntactic functions is needed for each language. For example, a determiner-noun dependency might be assumed to bear the DET (determiner) function, and an adjective-noun dependency is assumed to bear the ATTR (attribute) function. These functions are often produced as labels on the  dependencies themselves in the syntactic tree, e.g. The tree contains the following syntactic functions: ATTR (attribute), CCOMP (clause complement), DET (determiner), MOD (modifier), OBJ (object), SUBJ (subject), and VCOMP (verb complement). The actual inventories of syntactic functions will differ from the one suggested here in the number and types of functions that are assumed. In this regard, this tree is merely intended to be illustrative of the importance that the syntactic functions can take on in some theories of syntax and grammar.