Much work on XML data was around storage and querying and did not consider constraints of XML, especially keys. Since constraints have been proposed in many papers for XML, much research work on constraints has been being done. In this paper, we consider an important class of constraints, XML keys, and try to find the relationship between XML keys and relation keys. Given XML data whose semantics are represented in XML keys, we use a simple transformation language to express a transformation from the XML data to a relational database. Then we provide a formal definition of a relation tree that represents a well-formed rule on a relation written in the transformation language. After all rules that make up the transformation have been written, we show the way how XML data is transformed into relations. Finally, we present an algorithm for deriving relation keys from XML keys. These keys should be specified on the transformed relations or their compatibility with the predefined schem...