Schema Definition

Schema Definition

A schema is an outline, diagram, or model. In computing, schemas are often used to describe the structure of different types of data. Two common examples include database and XML schemas.

1. Database Schema

A database schema describes the tables and corresponding fields contained in a database. It may be displayed as a list of tables that each contain a sublist of fields along with the associated data type. More commonly, however, database schemas are displayed as visual diagrams. Boxes represent individual tables and lines show how the tables are connected. In some cases, these lines may include arrowheads to indicate the flow of data. Database schemas may also include comments that describe the purpose of each table and individual fields.

2. XML Schema

An XML schema defines the elements that an XML file may contain. It provides a specific structure for XML data, which is important when sharing XML files between multiple systems. Defining an XML schema ensures an XML document or feed will not contain unknown values, which may cause parsing errors. Below is an example of an XML schema, or XML schema definition (XSD).

<?xml version=”1.0″?>
<xs:schema xmlns:xs=”[url of a webpage that describes the schema]”>

  <xs:element name=”email”>
    <xs:complexType>,
      <xs:sequence>
        <xs:element name=”to” type=”xs:string”/>
        <xs:element name=”from” type=”xs:string”/>
        <xs:element name=”subject” type=”xs:string”/>
        <xs:element name=”body” type=”xs:string”/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

Schemas are most commonly used to describe databases and XML files, but they can also be used to describe other types of data. For example, a game developer may define a schema to describe 3D objects used in a video game. A software developer may use a schema to describe the structure of a file format used by an application.