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
379
votes
10 answers

What is the easiest way to ignore a JPA field during persistence?

I'm essentially looking for a "@Ignore" type annotation with which I can stop a particular field from being persisted. How can this be achieved?
m2o
  • 6,475
  • 6
  • 27
  • 24
376
votes
7 answers

T-SQL Cast versus Convert

What is the general guidance on when you should use CAST versus CONVERT? Is there any performance issues related to choosing one versus the other? Is one closer to ANSI-SQL?
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
374
votes
10 answers

Altering column size in SQL Server

How to change the column size of the salary column in the employee table from numeric(18,0) to numeric(22,5)
Sreedhar Danturthi
  • 7,119
  • 19
  • 68
  • 111
370
votes
8 answers

Rails :include vs. :joins

This is more of a "why do things work this way" question rather than a "I don't know how to do this" question... So the gospel on pulling associated records that you know you're going to use is to use :include because you'll get a join and avoid a…
Rob Cameron
  • 9,674
  • 7
  • 39
  • 42
368
votes
21 answers

Compare two MySQL databases

I'm currently developing an application using a MySQL database. The database-structure is still in flux and changes while development progresses (I change my local copy, leaving the one on the test-server alone). Is there a way to compare the two…
Vincent Ramdhanie
  • 102,349
  • 23
  • 137
  • 192
366
votes
9 answers

What are the performance characteristics of sqlite with very large database files?

2020 update, about 11 years after the question was posted and later closed, preventing newer answers. Almost everything written here is obsolete. Once upon a time sqlite was limited to the memory capacity or to 2 GB of storage (32 bits) or other…
Snazzer
  • 7,704
  • 5
  • 27
  • 25
365
votes
4 answers

What are OLTP and OLAP. What is the difference between them?

Actually what do they mean? All articles I find about them don't give me an idea, or my knowledge is too insufficient to understand it. Will some one give me some resources with which I can learn this from scratch.
Amarnath R Shenoy
  • 5,121
  • 8
  • 24
  • 32
361
votes
15 answers

Backup/Restore a dockerized PostgreSQL database

I'm trying to backup/restore a PostgreSQL database as is explained on the Docker website, but the data is not restored. The volumes used by the database image are: VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] and the…
Carl Levasseur
  • 4,203
  • 3
  • 19
  • 19
358
votes
15 answers

Difference between a user and a schema in Oracle?

What is the difference between a user and a schema in Oracle?
sengs
  • 6,647
  • 6
  • 30
  • 24
358
votes
9 answers

How to use multiple databases in Laravel

I want to combine multiple databases in my system. Most of the time the database is MySQL; but it may differ in future i.e. Admin can generate such a reports which is use source of heterogeneous database system. So my question is does Laravel…
Chintan7027
  • 7,115
  • 8
  • 36
  • 50
358
votes
14 answers

Auto Generate Database Diagram MySQL

I'm tired of opening Dia and creating a database diagram at the beginning of every project. Is there a tool out there that will let me select specific tables and then create a database diagram for me based on a MySQL database? Preferably it would…
cmcculloh
  • 47,596
  • 40
  • 105
  • 130
352
votes
14 answers

How to connect to MySQL from the command line

How can you connect to MySQL from the command line in a Mac? (i.e. show me the code) I'm doing a PHP/SQL tutorial, but it starts by assuming you're already in MySQL.
Leahcim
  • 40,649
  • 59
  • 195
  • 334
350
votes
12 answers

What's the fastest way to do a bulk insert into Postgres?

I need to programmatically insert tens of millions of records into a Postgres database. Presently, I'm executing thousands of insert statements in a single query. Is there a better way to do this, some bulk insert statement I do not know about?
Ash
  • 24,276
  • 34
  • 107
  • 152
350
votes
17 answers

Rename a table in MySQL

Renaming a table is not working in MySQL RENAME TABLE group TO member; The error message is #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group…
Anil Olakkal
  • 3,734
  • 2
  • 17
  • 17
348
votes
14 answers

What are the differences between B trees and B+ trees?

In a b-tree you can store both keys and data in the internal and leaf nodes, but in a b+ tree you have to store the data in the leaf nodes only. Is there any advantage of doing the above in a b+ tree? Why not use b-trees instead of b+ trees…
simplfuzz
  • 12,479
  • 24
  • 84
  • 137