Questions tagged [database]

This tag is for general database questions. If you question is specific to SQL or NoSQL, use the corresponding tags instead.

For questions about structuring the data within a database, please use database-design tag instead.

2087 questions
243
votes
13 answers

Is it a bad practice to store large files (10 MB) in a database?

I am currently creating a web application that allows users to store and share files, 1 MB - 10 MB in size. It seems to me that storing the files in a database will significantly slow down database access. Is this a valid concern? Is it better to…
B Seven
  • 3,105
  • 3
  • 16
  • 14
241
votes
13 answers

Why use a database instead of just saving your data to disk?

Instead of a database I just serialize my data to JSON, saving and loading it to disk when necessary. All the data management is made on the program itself, which is faster AND easier than using SQL queries. For that reason I have never understood…
MaiaVictor
  • 5,820
  • 7
  • 27
  • 45
235
votes
17 answers

Is it good practice to always have an autoincrement integer primary key?

In my databases, I tend to get into the habit of having an auto-incrementing integer primary key with the name id for every table I make so that I have a unique lookup for any particular row. Is this considered a bad idea? Are there any drawbacks to…
AJJ
  • 2,938
  • 4
  • 14
  • 14
194
votes
3 answers

How is localStorage different from indexedDB?

localStorage and indexedDB are used for offline storage of data in HTML5. What are their key differences and which one is preferable in what situations?
user52009
171
votes
9 answers

When would someone use MongoDB (or similar) over a Relational DBMS?

I'm a bit confused about the whole NoSQL thing and such. When would you choose to use something like MongoDB over something like Oracle or MySQL? I don't really understand the "difference" as far as usage goes between them. From my understanding…
user6791
147
votes
10 answers

How much business logic should the database implement?

I've worked in some projects where most of the business logic was implemented on the database (mostly through stored procedures). On the other side, I've heard from some fellow programmers that this is a bad practice ("Databases are there to store…
Raphael
  • 1,987
  • 2
  • 16
  • 15
140
votes
4 answers

Creating database connections - Do it once or for each query?

At the moment I create a database connection when my web page is first loaded. I then process the page and run any queries against that conection. Is this the best way to do it or should I be creating a database connection each time I run a…
webnoob
  • 2,139
  • 3
  • 19
  • 20
133
votes
17 answers

How do you store "fuzzy dates" into a database?

This is a problem I've run into a few times. Imagine you have a record that you want to store into a database table. This table has a DateTime column called "date_created". This one particular record was created a long time ago, and you're not…
nbv4
  • 1,552
  • 2
  • 11
  • 17
128
votes
10 answers

Storing a re-orderable list in a database

I'm working on a wishlist system, where users can add items to their various wishlists, and I plan to allow users to re-order the items later on. I am not really sure about the best way to go about storing this in a database while remaining fast and…
Tom Brunoli
  • 1,383
  • 2
  • 9
  • 6
103
votes
3 answers

What's the difference between MariaDB and MySQL?

What's the difference between MariaDB and MySQL? I'm not very familiar with both. I'm primarily a front end developer for the most part. Are they syntactically similar? Where do these two query languages differ? Wikipedia only mentions the…
chrisjlee
  • 2,060
  • 4
  • 17
  • 19
101
votes
9 answers

Is it ever okay to use lists in a relational database?

I've been trying to design a database to go with a project concept and ran into what seems like a hotly debated issue. I've read a few articles and some Stack Overflow answers that state it's never (or almost never) okay to store a list of IDs or…
linus72982
  • 951
  • 2
  • 6
  • 7
100
votes
10 answers

Why is "Select * from table" considered bad practice

Yesterday I was discussing with a "hobby" programmer (I myself am a professional programmer). We came across some of his work, and he said he always queries all columns in his database (even on/in production server/code). I tried to convince him not…
the baconing
  • 1,111
  • 2
  • 8
  • 9
94
votes
8 answers

Why would you store an enum in DB?

I've seen a number of questions, like this, asking for advice on how to store enums in DB. But I wonder why would you do that. So let's say that I have an entity Person with a gender field, and a Gender enum. Then, my person table has a column…
user3748908
  • 1,607
  • 2
  • 14
  • 15
83
votes
2 answers

Why are concurrent writes not allowed on an SQLite database?

I am doing database programming using Java with SQLite. I have found that only one connection at a time to the database has write capabilities, while many connections at once have read capability. Why was the architecture of SQLite designed like…
SteelToe
  • 1,539
  • 3
  • 13
  • 22
81
votes
12 answers

SQL: empty string vs NULL value

I know this subject is a bit controversial and there are a lot of various articles/opinions floating around the internet. Unfortunatelly, most of them assume the person doesn't know what the difference between NULL and empty string is. So they tell…
Jacek Prucia
  • 2,264
  • 1
  • 17
  • 15
1
2 3
99 100