I know the Data Model is basically two types ER-Model and Relational Model & Database schema is also two type Physical and logical.
But I can not understand what
The database schema is one that contains list of attributes and instructions to tell the database engine how data is organised whereas Data model is a collection of conceptional tools for describing data, data-relationship and consistency constraints.
As I understand it, a database schema is a physical entity, it describes the structure of exactly how the data is stored and is itself stored by DBMS for reference. Data model, on the other hand, is an abstract representation of database.
In my view Database model is prepared first and Database schema is followed by that . Data model gives the overall logical view of database model specially in term of their entity relationship whereas Database model is more concentric on entity and their attribute.
A schema can have multiple models related with it and each model can have multiple instances related with it.
for eg.
animalSchema{name:String, type:String}
mongoose.model('carnivores', animalSchema)
It simply means that carnivores is a model that is based on animalSchema.
mongoose.model('herbivores', animalSchema).
It simple means that herbivores is a model that is also based on animalSchema.
const lion = new carnivores();
const tiger = new carnivores();
These both are the instances of the carnivores model of the schema animalSchema
const deer = new herbivores();
const cow = new herbivores();
These both are the instances of the herbivores model of the schema animalSchema
A schema is a blueprint of the database which specifies what fields will be present and what would be their types. For example an employee
table will have an employee_ID
column represented by a string of 10 digits and an employee_Name
column with a string of 45 characters.
Data model is a high level design which decides what can be present in the schema. It provides a database user with a conceptual framework in which we specify the database requirements of the database user and the structure of the database to fulfill these requirements.
A data model can, for example, be a relational model where the data will be organised in tables whereas the schema for this model would be the set of attributes and their corresponding domains.
References: Understanding the schema and Database System Concepts (H Korth and A Silberschatz)
My Idea... A schema decides or describes the fields you will have in a document... while the model is the compilation of schema and ensures that any data moving in or out must conform to that schema