Using a DATE field as primary key of a date dimension with MySQL

后端 未结 2 1516
南方客
南方客 2021-01-11 20:11

I want to handle a date dimension in a MySQL datawarehouse. (I m a newbie in the DW world)

I made some searches with google and saw a lot of table structures (most

2条回答
  •  青春惊慌失措
    2021-01-11 20:25

    If you have a table with a column that is of date type and where no two rows will ever have the same date, then you can surely use this column as PRIMARY KEY.

    You see a lot of examples where the Primary Key is a simple UNSIGNED INTEGER because there are many cases where there is no perfect candidate for Primary Key. The AUTO_INCREMENT allows this column to be automatically filled by the database (and be unique) during inserts .

提交回复
热议问题