Data types for humans

We can do better.Herb CaudillBlockedUnblockFollowFollowingDec 23A key difference between a table in a spreadsheet and a table in a database is that database columns are typed: If you’re storing dates in a column, all the values in that column have to be dates.Consistent data types are a big part of what makes a database a database — and what makes a database more powerful than a spreadsheet.But, as we’ve seen, data types are also a key point of friction for non-technical users, because they have to be nailed down too early in the process.To get the best of both worlds, we want to avoid being heavy-handed: We don’t want to force Celeste to lay out her table schema in advance, but we do want to be smart and try to figure out her intentions..So if she types in a date, we’ll assume this is a date column..We’ll pick up the date format from the way she’s typed it in..And if she changes her mind and needs to change a column from one type to another, we want to make that as effortless as possible.We want a column to pick up the date format from the way it’s typed in — just as it would in Excel.Before we go any further with this, though, let’s talk about data types.Towards humane data typesI propose that the friction here doesn’t necessarily all come from having to choose a type in advance..The problem is also that most database systems force you to think about types from the computer’s perspective.You only have a few fundamental types to choose from (text, number, date, boolean) and within those categories you have to make some commitments about how much space the computer should set aside..So for example, if you’re going the store numbers in a column, the system really wants you to make a lot of decisions in advance about size, precision, and so on.SQL Server’s datatypes..Do you want int or bigint?.Any programmer worth her salt can tell you a story about making the wrong choice and coming to regret it.Human beings have different concerns..Does this number represent an amount in Euros or in Dollars?.Or is it a measure of weight, or length, or area?.What if it’s a distance in kilometers, but I want to show it in miles to some users?.Does this text represent phone numbers or RGB colors?With today’s databases, if you care about any of those things, you’re going to have to do the heavy lifting.So basically you, the human, have to give a lot of thought to implementation details that should be the computer’s concern; but then when you want the computer to help you out with silly things like currencies or countries or weights or measures or oh, I don’t know, BASICALLY ANYTHING HUMANS CARE ABOUT, you’re on your own.I think that’s the opposite of how it should be.So what data types would actually be helpful to Celeste?I think these categories ought to be front and center:Dates and timesPhysical measures: length, distance, weight, etc.Names, addresses, and other multi-part human artifactsCountries, states, currencies, languages, and other canonical listsReferences to other things in the same systemLet’s look at each of these in turn.Dates and timesThe passage of time is of fundamental concern to us humans, perhaps owing to the fact that we all die.Most computer systems have something like a datetime datatype that allows you to identify an instant in time, down to the millisecond: for example, Wednesday, June 7, 2018, 9:45:23.1234 (Greenwich Mean Time).And maybe that is, in fact, what we are interested in.But it’s often either a date with no time or a time with no date:June 7, 20189:45 AMOr, it could be a related, but distinct, concept such as:A duration:30 milliseconds5 days42 yearsA period of time:the year 2007the month of May 1997Quarter 1 of 2019A standalone day of the year, month or day of the week:every March 16every Februaryon TuesdaysToday’s databases are of very little help with managing these constructs.Now, there are libraries in most programming languages to help programmers represent these concepts cleanly.. More details

Leave a Reply