schema database example

 

schema database example

database schema example

A database schema example is the structure that describes the logical storage of data in a database. It is used to organize data and provide information about relationships between tables within a database. This topic will explain the types of database schema. Let's first define database schema before we can understand the basics of it.

What is Database?

A database is a storage area for information. A database can store simple data such as a list containing names, as well as more complex data. The information is stored in a structured format.

What is Database Schema?

  • The database schema is the logical representation for a database. It shows the way the data is stored in the database. It includes a list of attributes and instructions that tell the database engine how the data is organized.
  • A database schema can contain schema objects, which may include fields, views, packages, tables, and relationships.
  • The data may actually be stored in physical files, although it could be in an unstructured format. However, it is possible to retrieve the data and use it. A database schema is needed to do this. This schema provides information about the organization of data in a database as well as how it is related to other data.

Schema does not contain data; it provides information about data's shape and relationships to other tables and models.

  • The following are the components of a database schema object:

  1. Consistent formatting for all data entries.
  2. Unique keys and database objects for all data entries
  3. Multiple columns in a table, each column containing its name and datatype.

  • The project's size will determine the complexity and size of the schema. This allows developers to manage the database and organize it before they code it.
  • This diagram shows an example of a database scheme. It includes three tables and their data types. It also shows the relationships between primary keys and foreign keys.

database schema example

Different types of Database Schema

The database schema can be divided into three types:

database schema example


  • Physical Database Schema

A physical database schema describes how data will be stored on a storage device or disk. A physical schema is a way to design a database at the physical level.

  •  Logical Database Schema

Logical database schema identifies all the logic constraints that must be applied to stored data. It defines the views and integrity constraints. The term integrity constraints is used to describe the rules that DBMS (Database Management System), uses to maintain data quality. The logical schema describes how data is stored in tables and how they are linked.

Programmers and administrators are responsible for this level. The implementation of the data structure can be hidden from them.

ER modelling is a process that shows the relationships between components of data using a variety of tools.ER modeling is an acronym for entity-relationship modeling, which describes the relationships between entities.

An example of a basic commerce app can help us understand this concept. The schema diagram below shows the logical flow of transactions in a commerce app. The given example shows that the Ids of each circle are listed. These Ids can be used as primary or foreign key.

The primary key can be used to identify an entry in a record or document. The primary keys are identified by the Ids in the three upper circles. The Foreign key serves as the primary key to other tables. The FK is the foreign key in this diagram. It links one table to the other.

Logical Schema and  Physical Schema


  • View Schema

View schema is the name for the view level design in a database. This schema describes how the end-user interacts with the database systems.

There is a difference between the Logical and Physical Database Schema


  Physical database schema                                           Logical Database schema

1. It doesn't include the attributes.                                    1. It includes all attributes.

2. It has both primary and secondary Keys.                     2. It also has both primary and secondary keys.

3.It includes the table name.                                            3. It also contains the table names.

It includes the column names as well as their data types.   It doesn't contain any datatype or column names.

Database Instance and Database Schema are the same thing?

Database schema and database instances can sometimes be confused to be one thing. Both are distinct Database Schema represents a plan database but does not contain actual data.

A database instance, on the other hand is a snapshot of an actual database at a particular time. It can either change or vary depending on the time. The database schema, however, is static and difficult to modify.

Through the DBMS, both schemas and instances are linked to each other and have an impact on one another. DBMS ensures every instance of a database adheres to the constraints set by database schema designers.

Schema creation

In each database type, the "CREATE SCHEMA” statement is used to create a schema. Each DBMS uses a different terminology for this. We will explain how to create schema in different databases systems.

MySQL's "CREATE SCHEMA” statement creates a database. This is because MySQL's CREATE SCHEMA statement works in the same way as the CREATE DATABASE statements, and schema is a synonym of the database.

Each schema in Oracle Database is already available to each user. CREATE SCHEMA doesn't actually create a schema. It simply shows the schema with views and tables, and allows you to access them without having to run multiple SQL statements. To create an Oracle schema, use the "CREATE USER” statement.

The SQL server's "CREATE SCHEMA” statement creates a new schema using the name given by the user.

Database Schema Designs

The first step to building a solid foundation for data management is a schema design. Schema designs that are not well-designed can be difficult to manage and eat up more memory and other resources. It all depends on your business needs. To make project life easier, it is important to choose the right database schema design. Below is a list of popular database schema designs:

Flat Model

Flat Model

Flat model schemas are 2-D arrays in which each column has the same data type and all elements within a row have a relationship to one another. You can either view it as a single spreadsheet, or as a table in a database. This schema design works best for small applications with simple data.

Hierarchical Model

The Hierarchical model design has a tree-like structure. The tree structure includes the root node and its child nodes. There is a one to many relationship between each child node (or parent node) and each node. These database schemas can be presented in XML and JSON files. They can also contain entities and their sub-entities.

Hierarchical schema models work best for storing nested data such as Hominoid classification.

Network Model

Hierarchical design has a network model that represents a series nodes and vertices. The network model permits many-to-many relationships, while the hierarchical model only allows one. The hierarchical model, on the other hand, only allows one-to-many relationships.

Applications that require spatial calculations are best suited for network model design. It's also useful for representing workflows, and especially for cases that involve multiple paths to the same outcome.

Relational Model

The relational model is used to store data in relational databases. To manipulate or calculate different values from data, there are relational operators.

Star Schema

Star schema is a new way to arrange data. This schema is ideal for large amounts of data storage and analysis. It works with "Facts", and "Dimensions". The fact is the numerical data point which runs business processes. Dimension is a description. Star Schema allows us to structure RDBMS data.

Snowflake Schema

The snowflake schema can be described as an adaptation of the star schema. The star schema has a main "Fact table" that contains the main data points as well as references to the dimension tables. However, snowflake allows dimension tables to have their own dimension table.


Post a Comment

5 Comments

  1. আপনার প্রতিটি পোষ্ট খুব হেল্পফুল। আশা করি এমন অনেক পোষ্ট করুন যাতে মানুষের উপকারে আছে।

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete