The Schema and Instance are the essential terms related to databases. The major difference between schema and instance lies within their definition where Schema is the formal description of the structure of database whereas Instance is the set of information currently stored in a database at a specific time.
Instance changes very frequently while the schema acquires changes in a seldom manner.
Content: Schema Vs Instance
|Basis for comparison||Schema||Instance|
|Basic||Description of the database.||Snapshot of a database at a specific moment.|
|Initial state||Empty||Always have some data.|
Definition of Schema
A schema is the complete design of database it is also known as intension. It is the collection of named objects. The names of tables, columns of each table, datatype, triggers, functions views packages and other objects are included in the schema. The changes in a schema are not applied so frequently, but occasionally changes need to be applied as the requirements of application changes. The schema modification or alteration is known as schema revolution.
Let’s take an example of the student database. The schema diagram for the student database could contain a table regarding to student’s information such as name, course detail, academic performance and other information. In the given below schema diagram, we are constructing two records named as student and course with their attributes.
The database system has various schemata separated according to the levels of abstraction such as physical, logical and external/subschema. Generally, DBMS assist one physical one logical and several sub-schemata.
- The physical schema is the lowest level of a schema which describes how the data stored on the disk or the physical storage.
- The logical schema is the intermediate level of a schema which describes the structure of the database to the database designers. It also specifies what relationship exists between the data.
- The external schema or subschema is the highest level of a schema which defines the views for the end users.
Definition of Instance
An instance is the information collected in a database at some specific moment, and it is also known as state or extension. It is a snapshot where the current state or occurrence of a database is framed at that moment. Each time when the data is inserted or deleted from the database changes the state of the database that is the reason why an instance of the database changes very often.
The schema of the database is specified to the DBMS when a new database is defined, at that time the corresponding database is empty, hence has an empty instance. The starting state of the database is acquired when the database is first loaded with initial data. From then onwards, each time the data is updated we get a new database instance. At any point in time, there is a current state associated with a database. The DBMS is partially accountable for confirming the valid instance of a database where the instance assures the structure and constraints specified in the schema.
Let’s take the similar example in the instance. Here the student construct will contain their individual entities in the attributes.
Key Differences Between Schema and Instance
- A schema is the design representation of a database whereas instance is the snapshot of a database at a particular moment.
- Instance changes very frequently, whenever data is removed or added in the database. As against, the changes in schema occurs rarely.
- For example, schema and instance can be easily perceived by analogy to a program. At the time of writing a program in a programming language, the variables of that program is declared at first, this is analogous to the schema definition. Additionally, each variable in a program must have some values associated at a particular time; this is similar to an instance.
Schema and instance are somehow related, a schema is the initial state of the database where the database is designed at first. On the other hand, an instance is a state when data is loaded into the database or when any change is acquired by the corresponding database. Schema is the detailed description of the structure of database whereas the information stored at a specific moment in a database is known as an instance.