Объяснение термина “Схема”

Предоставленный, это - contrieved пример, и с отношениями более сложного объекта могло бы быть более эффективно спрятать XML-файл, чем запись его программно, но конечно должно быть больше к нему, чем это?

я думаю, что имеет больше смысла поднимать "проводное соединение" в конфигурационном файле вместо того, чтобы делать его вручную в коде по нескольким причинам:

  1. конфигурация является внешней к Вашему коду.
  2. Изменения в обеспечении электричеством (чтобы сказать Вашему sawmill использовать другой экземпляр Saw) могут просто быть внесены во внешний файл (XML) и не требуют изменяющегося кода, перекомпиляции, повторного развертывания, и т.д.
  3. , Когда у Вас есть десятки классов и несколько слоев инжекции (например: у Вас есть сеть Controller класс, который добирается Service класс, который содержит Вашу бизнес-логику, которая использует DAO для получения Saw с из базы данных, которая становится DataSource введенной в него, и т.д.), вручную обеспечение электричеством сотрудников утомительно и требует нескольких дюжин строк кода, которые делают только обеспечение электричеством.
  4. Это - несколько меньше ясного "преимущества", но при наличии всего 'обеспечения электричеством', внешнего к коду, я думаю, что это помогает укрепить разработчикам идеи, которые являются в ядре внедрения зависимости, конкретно идея кодировать к интерфейсу, не реализации. С ручным обеспечением электричеством может быть легко снизиться в старые пути.
5
задан Zaki 10 October 2012 в 11:35
поделиться

8 ответов

Definition

A schema defines the structure of the data, whether you store it in a database or an XML file or elsewhere.

Example
Suppose you use a relational database server to store your company's data, and you have a "Customers" table, to track information for each customer. The schema for the Customer table might dictate that each customer entry should have a firstname, lastname, and phone number. When you create a customer entry you can store only those fields.

Constraints

Schema can specify whether a field is optional or required. In this example, you might require that ALL of those fields be present. If the schema were enforced by some mechanism, it would not be possible to enter a customer entry into the database without specifying a phone number. Or, your schema might specify a mobile phone number, as optional.

In this example, the schema doesn't have a slot for "size" as an element within the customer structure, so you cannot insert that element into any customer entry. On the other hand, a T-shirt company might use a customer schema that includes a "size" field. Schemas vary by the thing they are describing, and by the people or parties that use the schema.

As Applied to XML

XML schema just defines the structure of a conformant XML document. There's a W3C standard for formally describing the schema, XML Schema Definition, aka XSD. (See the primer for an informal description of it) There are also other ways to formally describe the structure, or schema of an XML doc, which are not dejure standard but serve the same purpose. Relax-NG is one.

Informal Schema

There are also informal - or at least, less formal - ways of describing schema, particularly around XML files or other formats. Providing am example XML file and a text description is one common, informal way of specifying the schema. I call this "informal" because a sample doc cannot possibly describe everything about the schema. But, a sample doc coupled with a few lines of english text describing what's intended, is often a good enough, or even the best, way to describe an XML schema. This is basically the way the majority of the web works.

Consider the case of JSON. It is now being used to store and transmit information, in some cases as a alternative to XML. As far as I know, there is no formal mechanism for describing a schema for JSON. There's no way to specify what an acceptable or "compliant" JSON document looks like. What people do instead is provide an example or template, and that's good enough. There's no enforcement. If you provide a JSON packet that conforms to the expected format, then it works as expected. If you don't, then it won't work.

Informal schema is also the way most old-school paper-based businesses work. They hand out a form and give some examples - "if you want to place an order, fill out the form in this way".

Enforcement or Validation

Schema may or may not be "enforced" automatically. A relational database server typically provides a strict schema enforcement. You MUST define the schema in order to create a table, and any database clients MUST conform to the schema. Some XML-based systems perform document validation against an XSD to enforce schema. Many do not. As I said, most of the web is much less formal.


In answer to the second part of your question,
creating a database schema for a Customer means defining those fields that belong to the customer entity (in an entity sense), or columns that can be stored in the customer table (in a database), or the attributes and child elements of a Customer element (in an xml document), as well as the constraints on same (is the field required, optional, etc)..

A constraint places a limit on the type or format of the data in a particular field. One example constraint is whether the field is required or optional. Another constraint might be: "a customer name cannot be solely comprised of numeric characters." A more strict constraint might say: "a customer name may not have any numeric characters at all." For the T-shirt company, a constraint might be: the "size" element must be one of {S,M,L,XL}. Formal schema languages allow you to specify these constraints explicitly, in a way that a computer program could verify compliance. In informal schema specifications, you would just write or say, "the size must be one of S,M,L,XL" and that covers it.

11
ответ дан 18 December 2019 в 05:36
поделиться

A schema is the framework or model of whatever it is you are trying to describe.

The database schema will show each table, and its fields and its relationships to other tables in the database, but it will not include any actual data.

The same goes for an XML schema, it will show you the framework of the XML document but not any data.

8
ответ дан 18 December 2019 в 05:36
поделиться

A schema is the description of the representation of data. It's the data structure - fields and types. Nothing more involved than that really.

4
ответ дан 18 December 2019 в 05:36
поделиться

Schemas describe entities and their inter-relationships.

A Schema is a Model.

An entity is a way of representing some object (in the Domain, which is the situation you are modelling).

4
ответ дан 18 December 2019 в 05:36
поделиться

From Wikipedia:

[XML Schema is] a way to define the structure, content and, to some extent, the semantics of XML documents.

The statement holds true for database schemas as well.

3
ответ дан 18 December 2019 в 05:36
поделиться

A database schema is a distinct namespace that is separate from a database user. You can think of a schema as a container of objects. Schemas can be created and altered in a database, and users can be granted access to a schema. A schema can be owned by any user, and schema ownership is transferable.

Importance of Database Schemas in SQL Server

0
ответ дан 18 December 2019 в 05:36
поделиться

Схема базы данных радикально отличается от схемы XML. Схема - это язык для определения структурной грамматики. Схема базы данных будет определять структуру с использованием собственных метаданных базы данных. Так что схема может формировать документ хранения данных с использованием собственных дескрипторов базы данных.

XML, однако, не является устройством хранения данных. XML - это метаязык, который представляет собой синтаксис для создания языков. Схема XML - это определяемый XML язык для создания формальной языковой грамматики. Разница между схемой XML и схемой базы данных состоит в том, что схема базы данных существует для представления данных, в то время как схема XML существует для представления структуры языка разметки без учета каких-либо данных, которые она может содержать или не содержать.

0
ответ дан 18 December 2019 в 05:36
поделиться

«Схема - это модель».

«Проблема в том, что для новичка это объяснение не проясняет»

Схема действительно является моделью. А модель - это все, что позволяет любому зрителю модели сформировать себе образ того, как будет выглядеть реальность, когда смоделированная вещь будет эффективно построена. Например, масштабная модель моста, который необходимо построить, и того, как он интегрируется в окружающую среду. Или бумажные планы дома, который будет построен.

Схема базы данных - это модель базы данных, которая позволит любому зрителю модели сформировать себе образ того, какую информацию регистрирует база данных (и, следовательно, какую вид информации может быть извлечен из него), какие ограничения применяются к зарегистрированной информации (т.е. каким правилам должна удовлетворять зарегистрированная информация),

0
ответ дан 18 December 2019 в 05:36
поделиться
Другие вопросы по тегам:

Похожие вопросы: