Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what exactly is database schema?

Tags:

sql-server

I am new in the CS field, and one thing is that before asking this question I already googled it, but that made me more confused between two definitions I have found, so I'm asking which one is correct? So in this link, I found multiple answers which one is correct? What is the purpose of database schema?

I found this. What's confusing for me I think is that they both definitions are different from each other Guide me..

1) A SQL schema is container of objects. For example, you may have a large enterprise application and then it's a good practice to use different schemas for different purposes (e.g. put HR related tables into HR schema, accounting related tables into Accounting schema and so on). A schema can be owned by any user, and the ownership is transferable.

2)the database schema is the definition that describes the entire configuration of the database, including all of its tables, relations, index, etc

my question is different I have read the multiple answers which are available but I found multiple answers that is what made me more confused

like image 619
Faizan Naeem Avatar asked Jul 17 '17 10:07

Faizan Naeem


2 Answers

Both are correct. "Schema" has multiple meanings. Your first meaning is the kind of schema you get with CREATE SCHEMA -- an object container. Your second meaning is the general meaning of "database schema" that's independent of SQL Server. Usually it's clear from context which meaning is intended -- "database schema" is typically singular, while "schemas" within a single database refer to the containers. So, if you wanted to be particularly confusing, you could talk about a database schema2 that has multiple schemas1 in it.

like image 88
Jeroen Mostert Avatar answered Oct 16 '22 20:10

Jeroen Mostert


Briefly speaking, Schema is the synonym for database instance

You can use both CREATE SCHEMA MYDATABASE and CREATE DATABASE MYDATABASE in relational database such as MySql to create a new database instance.

The word Schema was once thought to be too academic and somewhat later obsoleted.

Both are Okey, but Schema sounds a little geek.

like image 22
SedriX Avatar answered Oct 16 '22 22:10

SedriX