Questions tagged [schema]

Schema means shape, or more generally, plan. It may be XML schema or Database schema.

XML schema

An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself.

These constraints are generally expressed using some combination of grammatical rules governing the order of elements, Boolean predicates that the content must satisfy, data types governing the content of elements and attributes, and more specialized rules such as uniqueness and referential integrity constraints.

There are languages developed specifically to express XML schemas. The Document Type Definition (DTD) language, which is native to the XML specification, is a schema language that is of relatively limited capability, but that also has other uses in XML aside from the expression of schemas. Two more expressive XML schema languages in widespread use are XML Schema (with a capital S) and RELAX NG.

The mechanism for associating an XML document with a schema varies according to the schema language. The association may be achieved via markup within the XML document itself, or via some external means.

More info about XML schema

Database schema

A database schema of a database system is its structure described in a formal language supported by the database management system (DBMS) and refers to the organization of data to create a blueprint of how a database will be constructed (divided into database tables).

The formal definition of database schema is a set of formulas (sentences) called integrity constraints imposed on a database. These integrity constraints ensure compatibility between parts of the schema. All constraints are expressible in the same language. A database can be considered a structure in realization of the database language. The states of a created conceptual schema are transformed into an explicit mapping, the database schema. This describes how real world entities are modeled in the database.

A schema can contain formulas representing integrity constraints specifically for an application and the constraints specifically for a type of database, all expressed in the same database language.

In a relational database, the schema defines the tables, fields, relationships, views, indexes, packages, procedures, functions, queues, triggers, types, sequences, materialized views, synonyms, database links, directories, Java, XML schemas, and other elements.

More info about Database schema

References:

7547 questions
60
votes
2 answers

What does the ref attribute on an element in an XSD do?

Documentation seems to say that it references another element in the schema, but how could it be used - I've never seen it in schemas that I have worked with. Anyone got any nice use cases or something that could explain its use further?
Fiona - myaccessible.website
  • 14,481
  • 16
  • 82
  • 117
58
votes
4 answers

Query to show all tables and their collation

Is there a query that can be run in mysql that shows all tables and their default collation? Even better if there was on that could show all collations on all columns of all tables.
Parris Varney
  • 11,320
  • 12
  • 47
  • 76
57
votes
7 answers

Laying out a database schema for a calendar application

I want to write a calendar application. It is really recurring items that throw a wrench in the works for the DB schema. I would love some input on how to organize this. What if a user creates an event, and inputs that it repeats everyone Monday,…
Anthony D
  • 10,877
  • 11
  • 46
  • 67
57
votes
1 answer

PostgreSQL's schemas for multi-tenant applications

I'm learning about multi-tenant applications and how PostgreSQL's schemas can be used for this. Researching the subject, I ended up finding an article in which the author describes a poor experience when using PostgreSQL's schemas in multi-tenant…
viniciussss
  • 4,404
  • 2
  • 25
  • 42
57
votes
2 answers

Json Schema example for oneOf objects

I am trying to figure out how oneOf works by building a schema which validates two different object types. For example a person (firstname, lastname, sport) and vehicles (type, cost). Here are some sample objects: {"firstName":"John",…
Stanimirovv
  • 3,064
  • 8
  • 32
  • 56
55
votes
4 answers

Possible to set default schema from connection string?

With SQL Server 2005 and 2008 is it possible to set the default schema from the connection string? It'd be a lot easier if we didn't have to manually set the schema with SQL code.
Earlz
  • 62,085
  • 98
  • 303
  • 499
55
votes
7 answers

How to generate entire DDL of an Oracle schema (scriptable)?

Can anyone tell me how I can generate the DDL for all tables, views, indexes, packages, procedures, functions, triggers, types, sequences, synonyms, grants, etc. inside an Oracle schema? Ideally, I would like to copy the rows too but that is less…
Eric
  • 786
  • 1
  • 9
  • 16
54
votes
1 answer

How to update database table schemas with NHibernate schema generation?

I'm trying to figure out how to use NHibernate configuration with mapping to update table schemas, rather than dropping and recreating them. Currently I'm using the NHibernate.Tool.hbm2ddl.SchemaExport obj with FluentNHibernate to generate the…
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
54
votes
2 answers

Mongoose schema optional fields

I have a user schema with mongoose in nodejs like this userschema = mongoose.Schema({ org: String, username: String, fullname: String, password: String, email: String }); Except sometimes I need to add some more fields. The main…
HarveyBrCo
  • 805
  • 1
  • 9
  • 17
52
votes
10 answers

How to validate structure (or schema) of dictionary in Python?

I have a dictionary with config info: my_conf = { 'version': 1, 'info': { 'conf_one': 2.5, 'conf_two': 'foo', 'conf_three': False, 'optional_conf': 'bar' } } I want to check if the dictionary follows the…
Thyrst'
  • 2,253
  • 2
  • 22
  • 27
52
votes
3 answers

How to create schema containing list of objects using Avro?

Does anyone knows how to create Avro schema which contains list of objects of some class? I want my generated classes to look like below : class Child { String name; } class Parent { list children; } For this, I have written part of…
Shekhar
  • 11,438
  • 36
  • 130
  • 186
50
votes
2 answers

How to extend a schema in JSON schema?

I'm using JSON schema for data modelling. I define a base Document schema, that I later use to define model schemas (e.g. Product, Category, User, etc.). I'm doing this because I want all models to inherit certain structure/rules. For example every…
Panagiotis Panagi
  • 9,927
  • 7
  • 55
  • 103
49
votes
4 answers

JSON Schema - specify field is required based on value of another field

Wondering if this is possible with schema draft 03. I've gotten dependencies working elsewhere, I think there is possibly just some creative use of them required in order to use them for specifying the required property of some field. My current…
pospi
  • 3,540
  • 3
  • 27
  • 26
49
votes
3 answers

XML XSD Schema - Enforce Unique Attribute Values in Schema

Lets say I have a schema that defines the following XML: Value 1 Value 2 Value 3 Value 4 I would like, at a schema level, to…
MrEyes
  • 13,059
  • 10
  • 48
  • 68
49
votes
4 answers

Django and postgresql schemas

I've been trying to solve this one all week, help very much appreciated. I have various schemas in a postgres db and I would like to be able to map to them from within the same or across different django apps. Some of the schemas are…
Spatial Digger
  • 1,883
  • 1
  • 19
  • 37