What is important to keep in mind when designing a

2020-02-19 06:56发布

What is important to keep in mind when designing a database?

I don't want to limit your answer to my needs as I am sure that others can benefit from your insights as well. But I am planning a content management system for a multi-client community driven site.

23条回答
放荡不羁爱自由
2楼-- · 2020-02-19 07:41

"Normalize till it hurts; de-normalize till it works."

查看更多
ゆ 、 Hurt°
3楼-- · 2020-02-19 07:41

Make sure that as much meta data as possible is encoded in the model. It should be possible to infer almost any business rule or concept from just looking at the data model.

This means, take care to pick names that reflect the reality of the users (but don't be afraid to change their perception of reality if it helps the model).

Encode all constraints you can in the database. Don't rely on the application layer to only supply sensible data. Make sure that only sensible data can exist in the first place.

Don't do aggregate data in the model. Keep the model as atomic as possible. Either aggregate on the fly or run regular aggregation jobs into aggregate tables.

Pick a good partition between schemas. Some partitioning makes sense to do with foreign keys, and some by pure physical seperation.

查看更多
倾城 Initia
4楼-- · 2020-02-19 07:41

Don`t use a large set of columns as primary keys

查看更多
啃猪蹄的小仙女
5楼-- · 2020-02-19 07:43

(Assuming OLTP)

Normalisation of your data-structures. (Performance de-normalisations can generally follow later where needed)

http://en.wikipedia.org/wiki/Database_normalization

查看更多
一纸荒年 Trace。
6楼-- · 2020-02-19 07:43

If you'll be looking rows up by fields other than the primary key, make sure to index them.

查看更多
Fickle 薄情
7楼-- · 2020-02-19 07:45

If you have queries that you're going to be running A LOT, make them into stored procedures. They will almost always run faster.

查看更多
登录 后发表回答