Questions tagged [database-design]

For questions about structuring the data within a database. How to lay out tables, whether to use a relational DB or not, etc.

This tag can be used by questions on database design, such as which normalization, first second, third normal form, vs. de-normalization, vs. NoSQL, learning about etc...

1301 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
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
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
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
86
votes
7 answers

EAV - is it really bad in all scenarios?

I'm thinking to use an entity-attribute-value (EAV) model for some of the stuff in one of the projects, but all questions about it in Stack Overflow end up to answers calling EAV an anti-pattern. But I'm wondering if it is that wrong in all…
Giedrius
  • 1,304
  • 1
  • 10
  • 15
81
votes
7 answers

Code First vs. Database First

When I design and create the software I work on, I typically design and create the back-end SQL tables first and then move on to the actual programming. The project I'm currently working on has me down right puzzled though. This is probably due to a…
RubberDuck
  • 8,911
  • 5
  • 35
  • 44
76
votes
7 answers

Configuration data: single-row table vs. name-value-pair table

Let's say you write an application that can be configured by the user. For storing this "configuration data" into a database, two patterns are commonly used. The single-row table CompanyName | StartFullScreen | RefreshSeconds | …
Heinzi
  • 9,646
  • 3
  • 46
  • 59
66
votes
4 answers

Is it wasteful to create a new database table instead of using enum data type?

Suppose I have 4 types of services I offer (they are unlikely to change often): Testing Design Programming Other Suppose I have 60-80 of actual services that each fall into one of the above categories. For example, 'a service' can be "Test…
Dennis
  • 8,157
  • 5
  • 36
  • 68
64
votes
10 answers

When would you use a long, string ID instead of a simple integer?

I'd like to use Youtube as an example: they use IDs in the form of PEckzwggd78. Why don't they use simple integers? Or imgur.com - they also use IDs such as 9b6tMZS for images and galleries. Not sequential integers. Why don't they use integers…
Rakori
  • 787
  • 1
  • 5
  • 7
62
votes
10 answers

Is it premature optimization to add database indices?

A colleague of mine today suggested that we go through all of the queries in our application and to add indices accordingly. I feel this is premature optimisation because our application is not even released yet. I suggested to monitor for slow…
Marco de Jongh
  • 897
  • 6
  • 13
56
votes
4 answers

Why is using MySQL for a dictionary website a bad idea?

I'm planning to design and set up a database to store dictionary entries (usually single words) and their meaning in another language. So, for example, the table Glossary must have entry and definition and each table record has a reference to the id…
54
votes
7 answers

What happened to database constraints?

When I review database models for RDBMS, I'm usually surprised to find little to no constraints (aside PK/FK). For instance, percentage is often stored in a column of type int (while tinyint would be more appropriate) and there is no CHECK…
Arseni Mourzenko
  • 134,780
  • 31
  • 343
  • 513
54
votes
8 answers

Is the use of NoSQL Databases impractical for large datasets where you need to search by content?

I've been learning about NoSQL Databases for a week now. I really understand the advantages of NoSQL Databases and the many use cases they are great for. But often people write their articles as if NoSQL could replace Relational Databases. And there…
53
votes
13 answers

Is it necessary to create a database with as few tables as possible

Should we create a database structure with a minimum number of tables? Should it be designed in a way that everything stays in one place or is it okay to have more tables? Will it in anyway affect anything? I am asking this question because a…
Shaheer
  • 889
  • 1
  • 7
  • 14
52
votes
6 answers

Is denormalising a database for speed an anti-pattern?

I have a database with a 1:m relationship. I have to display a list of parents to the user rapidly on a home screen at startup. The parent shows a single piece of information that is a sum of a particular child field for that parent. I don’t want…
1
2 3
86 87