Skip to main content
Share Your Experience: Take the 2024 Developer Survey
54 votes

What's a universal way to store a geographical address/location in a database?

Google has developed a library that helps validate postal addresses for every country in the world, which you can use to design a schema to store this data. Look for the most common required fields ...
mitchdav's user avatar
  • 735
42 votes

What's a universal way to store a geographical address/location in a database?

The universal way to store a geographical address/location in a database is this one: [Address] nvarchar(max) not null This requires the least amount of programming code (and so cuts maintenance ...
Arseni Mourzenko's user avatar
42 votes
Accepted

Is domain driven design an anti-SQL pattern?

These days, you are likely to see reads (queries) handled differently than writes (commands). In a system with a complicated query, the query itself is unlikely to pass through the domain model (...
VoiceOfUnreason's user avatar
37 votes

What's a universal way to store a geographical address/location in a database?

There isn't one. Every country has different address formats. If you are lucky, and they have a format at all! Obviously latitude/longitude will give you a point on the globe, but it's not really ...
Ewan's user avatar
  • 76.4k
25 votes

Is domain driven design an anti-SQL pattern?

As I understand it, a main point is to split the Domain Logic (Business Logic) from the Infrastructure (DB, File System, etc.). This is the foundation of the misunderstanding: the purpose of DDD isn'...
Der Kommissar's user avatar
21 votes

What's a universal way to store a geographical address/location in a database?

The only universal format is to have a single text field which may have multiple lines of text. This will allow any possible address on earth.
JacquesB's user avatar
  • 59.7k
19 votes

Is domain driven design an anti-SQL pattern?

If you've ever been on a project where the organization paying to host the application decides that the database layer licenses are too expensive, you'll appreciate the ease of which you can migrate ...
Berin Loritsch's user avatar
14 votes

What's a universal way to store a geographical address/location in a database?

I have been developing software solutions to be used in many countries. We address this issue by starting with the larger entity first, i.e. country then have fields down to the least common or ...
Billsensei's user avatar
12 votes

Best way to model a singleton in a relational database

There is absolutely nothing wrong with a table with one row. If this is part of your design, you should enforce it. Give the table an identity column, give it a uniqueness constraint, then add a ...
John Wu's user avatar
  • 26.6k
9 votes

Is domain driven design an anti-SQL pattern?

The set manipulation logic that SQL is good at can be integrated with DDD no problem. Say for example I need to know some aggregate value, total count of product by type. Easy to run in sql, but slow ...
Ewan's user avatar
  • 76.4k
7 votes

A single field or 2 fields for "description" and "content" of Article?

Storing things that are logically two different things as one thing always means that you have to perform extra work when you actually want to treat them as different things. That seems like wasted ...
Kilian Foth's user avatar
7 votes
Accepted

How do services distribute their servers around the globe while maintaining their whole dataset intact?

Video distribution sites like YouTube are read heavy and bandwidth heavy data users, but in terms of complexity, they're relatively simple to scale. They're essentially a CDN type scaling where you ...
Lie Ryan's user avatar
  • 12.4k
6 votes
Accepted

How is one or more aggregate function implemented in most SQL engines?

I believe most of the "modern" RDBMS implementations are based on the Cascades optimization framework. I shall talk about how Microsoft SQL Server handles this, as that is the DBMS with which I am ...
Michael Green's user avatar
5 votes

How to create database, tables and stored procedures during installation of application

Many databases have a "dump" feature that creates a text-based representation of the database. MySQL has mysqldump, for example. Depending on your database, you can specify to only dump structures ...
FrustratedWithFormsDesigner's user avatar
5 votes
Accepted

Database modeling, software development, and version control

You should look into database migrations, it's a common strategy used on databases. Basically you associate your codebase with a database schema version. To keep your schema up to date you maintain a ...
Joppe's user avatar
  • 4,596
5 votes

Best way to model a singleton in a relational database

It's not clear to me that you have a problem that you need to solve. A single-row table is in no way a problem for the database itself, and allows you to apply data types and constraints to the data. ...
David Aldridge's user avatar
5 votes

API-oriented databases: is it maintained by the back or API team?

The API should completely hide the database. Regardless of SQL vs No-SQL approaches. That means that: The DB should be filled via calls to the API. Callers of the API don't have to know what the ...
Ewan's user avatar
  • 76.4k
4 votes

Conflict resolution for two-way sync

I guess there is no standard way to do it, each system uses their own policies for the conflict resolution. I made some simulations using two devices, computer and phone, and Google Spreadsheet to ...
Allan Veloso's user avatar
4 votes

When placing an order in a shop, should a snapshop be taken of the products in an order also?

Orders/Receipts Are a separate data structure to the product catalogue/shopping cart. The catalogue/shopping cart dynamically update. If the price goes up, so does the price of the item in the cart. ...
Kain0_0's user avatar
  • 16.2k
4 votes

How do services distribute their servers around the globe while maintaining their whole dataset intact?

This is a very broad question with a very broad answer. There are a lot of things involved. The examples you mentioned are distributed systems. The characteristics you mention are obtained by scaling ...
Bogdan's user avatar
  • 3,620
3 votes

using two database in .net

Use an ORM or Database Abstraction Layer There are a lot of existing tools and frameworks that will do the heavy lifting for you and allow you to support multiple databases while writing database-...
JDT's user avatar
  • 6,410
3 votes

using two database in .net

This is a situation where things have gone wrong for a lot of developers over the time. In a perfect world it would just be to inject the chosen connection everywhere a connection is needed. But SQL ...
Bent's user avatar
  • 2,576
3 votes
Accepted

How to show if a database is ACID or BASE?

The design of an ACID database is significantly different from that of a BASE database. ACID gives you assurances that a transaction will be complete. Distributing an ACID database adds significant ...
BillThor's user avatar
  • 6,270
3 votes

Best way to model a singleton in a relational database

It seems to me that you're using a database for something that should actually be stored as a file. Your description reminds me a lot of Wiki pages, where users can edit the content. In Wikis, or at ...
MichelHenrich's user avatar
3 votes

The challenges of removing/modifying entries from a database located in persistent storage

The approach you describe is the same which is used, for instance, by SQL Server. With time, the data file grows, and you have to run a maintenance plan in order to shrink it by moving pages from the ...
Arseni Mourzenko's user avatar
3 votes

Is domain driven design an anti-SQL pattern?

One of the possible ways to solve this dilemma is to think of SQL as of an assembly language: you rarely, if at all, code directly in it, but where performance matters, you need to be able to ...
Kyrylo Shpytsya's user avatar
3 votes

When placing an order in a shop, should a snapshop be taken of the products in an order also?

Yes, you are correct in needing a "snapshot" of the Product details at the time the sale is made. This technique as it related to SQL databases is often referred to as "denormalization". Basically, ...
GHP's user avatar
  • 4,441
3 votes
Accepted

As a client; how to present database needs to perspective designers?

Not an answer per se (but I didn’t want to be limited by the formatting options in comments) First, put yourself in the other person’s shoes. If I were to come to you to request you create something ...
Jim Grisham's user avatar
3 votes

Database Structure for The Best Efficiency

It depends what you want to do with the messages, which you don't elaborate (so we have to guess from the two words "group chat"). But this one has almost a general answer (with possible ...
Bruno Guardia's user avatar
2 votes
Accepted

Managing a development database in a group project

I am not a Laravel expert, but the problem you describe is not very special to that framework. You have different instances of a database, and you need to make sure when schema changes have to be ...
Doc Brown's user avatar
  • 209k

Only top scored, non community-wiki answers of a minimum length are eligible