Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL table with a single row? [closed]

Tags:

What is the point (if any) in having a table in a database with only one row?

Note: I'm not talking about the possibility of having only one row in a table, but when a developer deliberately makes a table that is intended to always have exactly one row.

Edit:

The sales tax example is a good one.

I've just observed in some code I'm reviewing three different tables that contain three different kinds of certificates (a la SSL), each having exactly one row. I don't understand why this isn't made into one large table; I assume I'm missing something.

like image 551
Jeremy Powell Avatar asked Jul 30 '09 18:07

Jeremy Powell


People also ask

What is a single row in a table?

Use. A single-row query is a SELECT statement that produces a result set with at most one row. For example, such statement could be a SELECT statement with a fully specified primary key.

How do I update only one row?

First, specify the table name that you want to change data in the UPDATE clause. Second, assign a new value for the column that you want to update. In case you want to update data in multiple columns, each column = value pair is separated by a comma (,). Third, specify which rows you want to update in the WHERE clause.

What is a temporal table in SQL?

Temporal tables (also known as system-versioned temporal tables) are a database feature that brings built-in support for providing information about data stored in the table at any point in time, rather than only the data that is correct at the current moment in time.


1 Answers

For some things you only need one row - typically system configuration data. For example, "current sales tax rate". This might change in the future and so shouldn't be hardcoded, but you'll typically only ever need one at any given time. This kind of data needs to be in the database so that queries can use it in computations.

like image 117
Vinay Sajip Avatar answered Sep 20 '22 22:09

Vinay Sajip