Questions tagged [database]

A database is an organized collection of data. It is the collection of schemas, tables, queries, reports, views, and other objects. The data are typically organized to model aspects of reality in a way that supports processes requiring information. Use this tag if you have questions about designing a database. If it is about a particular database management system, (e.g., MySQL), please use that tag instead.

From Wikipedia:

A database is an organized collection of data. It is the collection of tables, queries, reports, views and other objects. The data is typically organized to model aspects of reality in a way that supports processes requiring information, such as modelling the availability of rooms in hotels in a way that supports finding a hotel with vacancies.

A large proportion of websites and applications rely on databases. They are a crucial component of telecommunications systems, banking systems, video games, and just about any other software system or electronic device that maintains some amount of persistent information. In addition to persistence, database systems provide a number of other properties that make them exceptionally useful and convenient: reliability, efficiency, scalability, concurrency control, data abstraction, and high-level query languages. Databases are so ubiquitous and important that computer science graduates frequently cite their database class as the one most useful to them in their industry or graduate-school careers.2

The term database should not be confused with Database Management System (DBMS). A DBMS is the system software used to create and manage databases and provide users and applications with access to the database(s). A database is to a DBMS as a document is to a word processor.

Database Languages

Database languages are special-purpose languages, which do one or more of the following:

###ACID In computer science, ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties of database transactions.

  1. Atomicity - Atomicity requires that each transaction be "all or nothing": if one part of the transaction fails, then the entire transaction fails, and the database state is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors, and crashes. To the outside world, a committed transaction appears (by its effects on the database) to be indivisible ("atomic"), and an aborted transaction does not happen.

  2. Consistency - The consistency property ensures that any transaction will bring the database from one valid state to another. Any data written to the database must be valid according to all defined rules, including constraints, cascades, triggers, and any combination thereof. This does not guarantee correctness of the transaction in all ways the application programmer might have wanted (that is the responsibility of application-level code) but merely that any programming errors cannot result in the violation of any defined rules.

  3. Isolation - The isolation property ensures that the concurrent execution of transactions results in a system state that would be obtained if transactions were executed serially, i.e., one after the other. Providing isolation is the main goal of concurrency control. Depending on the concurrency control method (i.e., if it uses strict - as opposed to relaxed - serializability), the effects of an incomplete transaction might not even be visible to another transaction.

  4. Durability - The durability property ensures that once a transaction has been committed, it will remain so, even in the event of power loss, crashes, or errors. In a relational database, for instance, once a group of SQL statements execute, the results need to be stored permanently (even if the database crashes immediately thereafter). To defend against power loss, transactions (or their effects) must be recorded in a non-volatile memory.

A few notable DBMSs:

Popular Database tools

Some useful references:

Free online database courses:

193843 questions
37
votes
1 answer

Is there a simple way to tell alembic to migrate to a specific revision?

Alembic has commands to upgrade and downgrade to a specific revision, e.g. on the command line: alembic upgrade And alembic downgrade Is there a simple way to migrate to a specific revision if you don't know…
Matt
  • 2,153
  • 1
  • 18
  • 29
37
votes
5 answers

Creating new database in DataGrip JetBrains

Anybody know how to create new database in DataGrip (database IDE from JetBrains)? Could not find in DataGrip Help page.
Abduhafiz
  • 3,318
  • 5
  • 38
  • 48
37
votes
12 answers

Strange MySQL "read-only" error

I'm experiencing a strange MySQL error, seemingly related to the database's read-only flag. A Web application that uses MySQL is running on Debian 7.9. It was running well for weeks, if not more, while, suddenly, attempts to access the…
Aleksandr Blekh
  • 2,462
  • 4
  • 32
  • 64
37
votes
3 answers

Is it okay that database credentials are stored in plain text?

By default, the Django database host/user/password are stored in the project settings.py file in plain text. I can't seem to think of a better way at the moment, but this seems to be against best practices for password storage. Granted, if an…
pancakes
  • 741
  • 1
  • 7
  • 15
37
votes
6 answers

A good database modeling tool for PostgreSQL?

PostgreSQL comes with the excellent pgAdmin-tool for managing the database but lacks GUI data-modeling utility? I found this list: http://www.databaseanswers.org/modelling_tools.htm but don't have time to evaluate them. Which one do YOU recommend?
huug
  • 1,059
  • 2
  • 11
  • 25
37
votes
16 answers

How would you implement sequences in Microsoft SQL Server?

Does anyone have a good way of implementing something like a sequence in SQL server? Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and…
Nathan Lee
  • 2,231
  • 2
  • 23
  • 26
37
votes
5 answers

Are there any databases that support protocol buffers?

Are there any databases, in either the SQL or NoSQL worlds, that support protocol buffers? (Support could mean various things, but hopefully would include being able to index on fields in protocol buffers.)
Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99
37
votes
3 answers

EF Code-First One-to-one relationship: Multiplicity is not valid in Role * in relationship

I'm attempting to do the following: public class class1 { public int Id {get;set;} [ForeignKey("Class2")] public int Class2Id {get;set;} public virtual Class2 Class2 {get;set;} } public class class2 { public int Id { get; set;} …
37
votes
1 answer

Is multi-AZ RDS really worth it?

Looking at the prices for RDS instances, the multi-AZ instances cost double. Having a production environment in mind, does it worth it? What uptime should I expect from a single-AZ instance, as opposed to a multi-AZ one? Has anyone had experience…
37
votes
5 answers

Query to find tables modified in the last hour

I want to find out which tables have been modified in the last hour in a MySQL database. How can I do this?
agente_secreto
  • 7,959
  • 16
  • 57
  • 83
37
votes
5 answers

Group by multiple columns in Laravel

How to GROUP BY multiple column in Laravel? I tried this code: $routes = DB::table('route') ->groupBy('rte_origin') ->groupBy('rte_destination') ->get(); But this is not working.
satjan
  • 471
  • 1
  • 5
  • 11
37
votes
1 answer

escaping dash in username

I'm having difficulty modifying a postgres user that contains a dash in its name - I've run into this problem several times, but can never find the answer (no matter how much googling I do!). osm=# grant all on osm_polygon_view to www-data; ERROR: …
gavz
  • 1,151
  • 1
  • 8
  • 8
37
votes
7 answers

How to create an alias of database in SQL Server

We have a very old software has been created around 10 years ago and we don't have source code. The software uses two databases, DB01 and DB02 on the same SQL Server 2012 instance. There is SQL statements such as db01..table1 join db02..table2, but…
Dmitriy Sosunov
  • 1,075
  • 3
  • 10
  • 25
37
votes
6 answers

Getting execute permission to xp_cmdshell

I am seeing an error message when trying to execute xp_cmdshell from within a stored procedure. xp_cmdshell is enabled on the instance. And the execute permission was granted to my user, but I am still seeing the exception. The EXECUTE permission…
David Griffiths
  • 640
  • 1
  • 7
  • 14
37
votes
1 answer

Django: Detect database backend

I'm doing some "extra" queries in Django that need to work on both sqlite and postgres. The syntax of these queries varies between backend but I have no way of figuring out if I'm sending my queries to either postgres or sqlite. Is there a way to…
jaap3
  • 2,696
  • 19
  • 34