{"id":712,"date":"2016-06-06T21:07:36","date_gmt":"2016-06-07T04:07:36","guid":{"rendered":"https:\/\/database.guide\/?p=712"},"modified":"2016-06-20T00:20:32","modified_gmt":"2016-06-20T07:20:32","slug":"schema-definitions-by-dbms","status":"publish","type":"post","link":"https:\/\/database.guide\/schema-definitions-by-dbms\/","title":{"rendered":"Schema Definitions by DBMS"},"content":{"rendered":"<p>Different database management systems define <i>schema<\/i> in their own way. This can\u00a0make it difficult for database developers to work out <a href=\"https:\/\/database.guide\/what-is-a-database-schema\/\">exactly what a schema is<\/a> &#8211; especially when switching between different DBMSs.<\/p>\n<p>This article provides\u00a0definitions used\u00a0by the three leading database systems.<\/p>\n<p><!--more--><\/p>\n<h2>\u00a0MySQL<\/h2>\n<p>The <a href=\"https:\/\/database.guide\/what-is-mysql\/\">MySQL<\/a> documentation defines a schema from both a conceptual and a physical standpoint.<\/p>\n<h3>Conceptual<\/h3>\n<blockquote><p>Conceptually, a schema is a set of interrelated database objects, such as tables, table columns, data types of the columns, indexes, foreign keys, and so on. These objects are connected through SQL syntax, because the columns make up the tables, the foreign keys refer to tables and columns, and so on. Ideally, they are also connected logically, working together as part of a unified application or flexible framework.\u00a0For example, the <span class=\"bold\"><strong>information_schema<\/strong><\/span> and <span class=\"bold\"><strong>performance_schema<\/strong><\/span> databases use &#8220;schema&#8221; in their names to emphasize the close relationships between the tables and columns they contain.<\/p><\/blockquote>\n<h3>Physical<\/h3>\n<p>It is then pointed out that, from a physical standpoint, there&#8217;s\u00a0no distinction between schemas and databases:<\/p>\n<blockquote><p>In MySQL, physically, a <span class=\"bold\"><strong>schema<\/strong><\/span> is synonymous with a <span class=\"bold\"><strong>database<\/strong><\/span>. You can substitute the keyword <code class=\"literal\">SCHEMA<\/code> instead of <code class=\"literal\">DATABASE<\/code> in MySQL SQL syntax, for example using <code class=\"literal\">CREATE SCHEMA<\/code> instead of <code class=\"literal\">CREATE DATABASE<\/code>.<\/p><\/blockquote>\n<p>Source:\u00a0<a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/glossary.html#glos_schema\">&#8220;MySQL Glossary&#8221;<\/a>. MySQL 5.7 Reference Manual. MySQL. Retrieved 6 June 2016.<\/p>\n<h2>SQL Server<\/h2>\n<h3>Glossary<\/h3>\n<blockquote><p><dfn>Database Schema<\/dfn><\/p>\n<p>The names of tables, fields, data types, and primary and foreign keys of a database.<\/p><\/blockquote>\n<p>Source:\u00a0<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ms165911.aspx\">&#8220;Glossary&#8221;<\/a>. SQL Server 2016 Technical Documentation. Microsoft Developer Network.\u00a0Retrieved 6 June 2016.<\/p>\n<h3>SQL Server Technical Article<\/h3>\n<p>This <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/dd283095(v=sql.100).aspx\">article about database object schemas<\/a>, explicitly\u00a0draws the distinction between a database user and schema (this is in contrast to how Oracle defines schemas &#8211; below).<\/p>\n<blockquote><p>A schema is a distinct namespace to facilitate the separation, management, and ownership of database objects.<\/p><\/blockquote>\n<p>and<\/p>\n<blockquote><p>An object owned by a database user is no longer tied to that user. The object now belongs to a schema \u2013 a container that can hold many database objects.<\/p><\/blockquote>\n<p>and<\/p>\n<blockquote><p>This separation means objects and schemas can be created before users are added to the database. It also means a user can be dropped without specifically dropping the objects owned by that user.<\/p><\/blockquote>\n<p>Source:\u00a0<a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/dd283095(v=sql.100).aspx\">&#8220;SQL Server Best Practices \u2013 Implementation of Database Object Schemas&#8221;<\/a>. Microsoft TechNet article. Published: November 2008. Retrieved 6 June 2016.<\/p>\n<h2>Oracle Database<\/h2>\n<p><a href=\"https:\/\/database.guide\/what-is-oracle-database\/\">Oracle Database<\/a>&#8216;s schema system is quite different to the other systems. Oracle&#8217;s schema is very much tied to the database user.<\/p>\n<blockquote><p>A <span class=\"bold\">schema<\/span> is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema.<\/p><\/blockquote>\n<p>Oracle distinguishes between <i>schema objects<\/i> and <i>nonschema objects<\/i>. So in other words, some database objects cannot be included in a schema.<\/p>\n<h3>Schema Objects<\/h3>\n<p>In Oracle Database, <i>schema objects<\/i> include the following:<\/p>\n<ul>\n<li>Clusters<\/li>\n<li>Constraints<\/li>\n<li>Database links<\/li>\n<li>Database triggers<\/li>\n<li>Dimensions<\/li>\n<li>External procedure libraries<\/li>\n<li>Index-organized tables<\/li>\n<li>Indexes<\/li>\n<li>Indextypes<\/li>\n<li>Java classes, Java resources, Java sources<\/li>\n<li>Materialized views<\/li>\n<li>Materialized view logs<\/li>\n<li>Mining models<\/li>\n<li>Object tables<\/li>\n<li>Object types<\/li>\n<li>Object views<\/li>\n<li>Operators<\/li>\n<li>Packages<\/li>\n<li>Sequences<\/li>\n<li>Stored functions, <a href=\"https:\/\/database.guide\/what-is-a-stored-procedure\/\">stored procedures<\/a><\/li>\n<li>Synonyms<\/li>\n<li><a href=\"https:\/\/database.guide\/what-is-a-table\/\">Tables<\/a><\/li>\n<li><a href=\"https:\/\/database.guide\/what-is-a-view\/\">Views<\/a><\/li>\n<\/ul>\n<h3>Nonschema Objects<\/h3>\n<p>In Oracle Database, the following objects are\u00a0<i>nonschema objects<\/i>:<\/p>\n<ul>\n<li>Contexts<\/li>\n<li>Directories<\/li>\n<li>Editions<\/li>\n<li>Restore points<\/li>\n<li>Roles<\/li>\n<li>Rollback segments<\/li>\n<li>Tablespaces<\/li>\n<li>Users<\/li>\n<\/ul>\n<p>Source:\u00a0<a href=\"https:\/\/docs.oracle.com\/database\/121\/SQLRF\/sql_elements007.htm#SQLRF20003\">&#8220;Database Objects&#8221;<\/a>. \u00a0Oracle Database Online Documentation 12c Release 1 (12.1). Oracle Help Center.\u00a0Retrieved 6 June 2016.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Different database management systems define schema in their own way. This can\u00a0make it difficult for database developers to work out exactly what a schema is &#8211; especially when switching between different DBMSs. This article provides\u00a0definitions used\u00a0by the three leading database systems.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,6,7,5],"tags":[31,32],"class_list":["post-712","post","type-post","status-publish","format-standard","hentry","category-database-concepts","category-mysql","category-sql","category-sql-server","tag-database-schema","tag-oracle"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=712"}],"version-history":[{"count":8,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/712\/revisions"}],"predecessor-version":[{"id":1015,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/712\/revisions\/1015"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}