3

I'm new to databases, and is exploring SQL vs noSQL.

What kind of data is highly relational and benefits from SQL and what kind of data does not?

Please provide some examples.

Mark
  • 32,293
  • 33
  • 107
  • 137
  • possible duplicate of [Why should I use document based database instead of relational database?](http://stackoverflow.com/questions/441441/why-should-i-use-document-based-database-instead-of-relational-database) – Sean Vieira Jun 22 '11 at 21:31
  • 1
    Highly relational stuff: book-keeping (general ledger), inventory and order/sales systems, almost anything that's currently existing under the "line-of-business" application umbrella, really... – marc_s Jun 22 '11 at 21:37
  • Things like menus with parent child rankings and boss-employee rankings are usually considered hierarchical and less suited to and more difficult to work with in a relational database. – mikeY Jun 22 '11 at 21:59

2 Answers2

2

Your question seems to be burdened with a few misconceptions. Relational as in Relational Database refers to a type of data model - the system of representation used for data. Any information that consists of facts (propositions) can be represented relationally if your DBMS supports that type of information. There is no intrinsic quality of any information that makes it more or less suitable for an RDBMS.

SQL is a (strictly non-relational) database language.

NOSQL is a loose term that can be applied to any database system that doesn't use SQL or that extends the capabilities of SQL. NOSQL and relational are not mutually exclusive concepts. NOSQL does not have to mean "non-relational", it just means "not SQL".

nvogel
  • 24,981
  • 1
  • 44
  • 82
  • So what? Mark asked what data works **well** with SQL; and he did not bring up the popular “NoSQL is a single thing” misconception. – Tobu Jun 22 '11 at 22:19
  • He asked "What kind of data *is* highly relational", which is what I was trying to answer. – nvogel Jun 22 '11 at 22:36
  • +1 I assume by "representation" you are referring to both structure and operators ;) – onedaywhen Jun 23 '11 at 07:50
2

Relational data fits into the definition of a relation:

  • A header defines a finite set of columns.
  • Each column has a name and a data type.
  • Data types are a named, finite set of distinct values.
  • Each column in a given row of the relation contains one value of the appropriate data type for the respective column.
  • Rows have no implicit order.
  • Columns have no implicit order.
  • Duplicate rows are not allowed.

These conditions are prerequisites for all the Normal Forms of relations. That is, a table doesn't qualify even for First Normal Form unless it's a relation. Many operations in SQL don't work right if the table isn't relational.

To be more practical, a relational table must have the same properties on every row, by the same names, and must have a primary key defined over one or more columns so you can reference each row individually.

NoSQL is actually a marketing term used to brand and promote some data management products. It's not a computer science term.

But if you mean non-relational, then you can see that a non-relational data store is allowed to break some of the rules above:

  • Two entries (rows) in a given collection can be duplicates.
  • The fields can vary per entry. Different number, different names, different data types.
  • A given field can contain the same value in two entries, yet the value is considered different for some reason (for example, depending on the value in another field).
  • Order of entries is significant (for example, the entries are assumed to be in chronological order).
  • Order of fields is significant (for example, the first field is assumed to be a key of some kind).

But by breaking these rules, you lose the foundation on which relational operations work.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • "A header defines a finite set of columns": I think you meant to say, "A *heading* defines a finite set of *attributes*". Similarly, your use SQL or otherwise informal terms to try to express the meaning of 'relation' and to be honest I don't think it works -- I think just a link to a formal definition would suffice ;) – onedaywhen Jun 23 '11 at 08:01
  • @onedaywhen: Thanks, I do support using precise terminology where I can, but a StackOverflow post is not the place to introduce people to all the terms needed for formal definitions. I make a few sacrifices and use informal terms that will be more familiar to readers. For a more full description of what it means to be a relation, I'd recommend "SQL and Relational Theory" by C. J. Date. – Bill Karwin Jun 23 '11 at 14:24