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
36
votes
11 answers

Normalization in plain English

I understand the concept of database normalization, but always have a hard time explaining it in plain English - especially for a job interview. I have read the wikipedia post, but still find it hard to explain the concept to non-developers. …
Yada
  • 30,349
  • 24
  • 103
  • 144
36
votes
4 answers

Database EAV Pros/Cons and Alternatives

I have been looking for a database solution to allow user defined fields and values (allowing an unlimited number). At first glance, EAV seemed like the right fit, but after some reading I am not sure anymore. What are the pros and cons of EAV? Is…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
36
votes
4 answers

How to create FULLTEXT index on multiple columns?

I am running the following query on tbl_query select * from tbl_query q where match(q.query_desc,q.query_desc_details) against ('test1' WITH QUERY EXPANSION); It's giving an error 16:46:22 select * from tbl_query q where…
Pradeep Kr Kaushal
  • 1,506
  • 1
  • 16
  • 29
36
votes
11 answers

Represent Ordering in a Relational Database

I have a collection of objects in a database. Images in a photo gallery, products in a catalog, chapters in a book, etc. Each object is represented as a row. I want to be able to arbitrarily order these images, storing that ordering in the…
tghw
  • 25,208
  • 13
  • 70
  • 96
36
votes
3 answers

Command-line/API for Schema Compare in SSDT SQL Server Database Project?

In Visual Studio 2012, we have Schema Compare in SSDT's SQL Server Database Project (DbProject) project which helps Compare source versus target Update target to make it the same as source Where Source and target can be either a database, a…
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
36
votes
17 answers

When to use SQL Table Alias

I'm curious to know how people are using table aliases. The other developers where I work always use table aliases, and always use the alias of a, b, c, etc. Here's an example: SELECT a.TripNum, b.SegmentNum, b.StopNum, b.ArrivalTime FROM Trip a,…
Rossini
  • 5,960
  • 4
  • 29
  • 32
36
votes
1 answer

Why does Add-Migration sometimes create duplicate migrations?

I am facing a weird problem with code first migrations in Entity Framework version 5. Sometimes Update-Database fails due to pending changes but Add-Migration command only produces migrations with database changes already contained in the last…
Jan Deinhard
  • 19,645
  • 24
  • 81
  • 137
36
votes
6 answers

How to connect to remote Oracle DB with PL/SQL Developer?

I have a database "TEST", to which I connect at address 123.45.67.89:1521. How do I connect to it using PL/SQL Developer?
Mikhail Orlov
  • 2,789
  • 2
  • 28
  • 38
36
votes
2 answers

Error ORA-00932 when using a select with union and CLOB fields

First of all, this isn't a duplicate of this question. If it is, sorry but I couldn't solve my problem by reading it. I'm getting this error: ORA-00932: inconsistent datatypes: expected - got CLOB When I try to execute this SELECT statement: SELECT…
gabsferreira
  • 3,089
  • 7
  • 37
  • 61
36
votes
4 answers

Oracle SQL query for Date format

I always get confused with date format in ORACLE SQL query and spend minutes together to google, Can someone explain me the simplest way to tackle when we have different format of date in database table ? for instance i have a date column as…
user2246725
  • 470
  • 1
  • 6
  • 9
36
votes
4 answers

Any experiences with Protocol Buffers?

I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it? I'm currently using XML in a Python project for structured content…
saint_groceon
  • 6,167
  • 5
  • 32
  • 26
36
votes
6 answers

Exporting from SQLite to SQL Server

Is there a tool to migrate an SQLite database to SQL Server (both the structure and data)?
Geoff Appleford
  • 18,538
  • 4
  • 62
  • 85
36
votes
2 answers

how to select distinct value from multiple tables

I need to get distinct values from 3 tables. When I perform this code: select DISTINCT(city) from a,b,c I get an error which says that my column 'city' is ambiguous. Also I have tried this: select DISTINCT(city) from a NATURAL JOIN b NATURAL JOIN…
user123_456
  • 5,635
  • 26
  • 84
  • 140
36
votes
2 answers

Difference between ManyToOneRel and ForeignKey?

In django, what's the difference between a ManyToOneRel and a ForeignKey field?
sfendell
  • 5,415
  • 8
  • 25
  • 26
36
votes
4 answers

How to give a user only select permission on a database

I want a to create a new user on a db with only the select permissions (read only access) how can i do this ? i'm working with sql 2008
stanja
1 2 3
99
100