简体   繁体   English

Firebird中的域

[英]Domains in Firebird

I have a general questions about domains. 我对域有一个一般性的问题。 I recogniced, that when I create a table and I don't use a domain, a default domain will be created, such as RDB$1, RDB$2, RDB$3, aso. 我认识到,当我创建表并且不使用域时,将创建一个默认域,例如RDB $ 1,RDB $ 2,RDB $ 3,aso。 Here are my questions: - What impact has the default created domain? 我的问题是:-默认创建的域有什么影响? - Does these enlarge my database size? -这些会扩大我的数据库大小吗? - Does these have an inpact of the performance? -这些对表演有影响吗? - Shall I create a domain for every data type I use, and use the domain instead? -我应该为我使用的每种数据类型创建一个域,而是使用该域吗?

thx 谢谢

Impact and size are very small. 影响和规模很小。

It's better to use domain because when you update one : you update it for all the fields who use it. 最好使用域,因为在更新域时:会为使用域的所有字段更新它。

The default created domain has the same impact as a user created domain. 默认创建的域与用户创建的域具有相同的影响。

In any case the space occupied by the specific action of creating domain (user or default created) is related only to the data stored in system tables that define the domain itself; 无论如何,创建域的特定操作(用户或默认创建的)所占用的空间仅与定义域本身的系统表中存储的数据有关; there is no impact on the space occupied by data stored in the database. 对存储在数据库中的数据所占用的空间没有影响。

In database containing real data the space occupied by metadata is negligible compared to space occupied by data, so the impact of domains is quite nothig. 在包含实际数据的数据库中,元数据所占的空间与数据所占的空间相比可以忽略不计,因此域的影响不是很大。

The use of user domains is advised for readability and maintenance purpose. 建议出于可读性和维护目的使用用户域。

The only impact on performance is visible in administration tools which need to fetch info from domains. 对性能的唯一影响在需要从域中获取信息的管理工具中可见。 If you have a database with, let's say, 500 tables having 20 columns on average, that's 10000 domains. 假设您的数据库平均有500个表,其中有20列,那就是10000个域。 If you use custom domains, you might have 50 or so. 如果使用自定义域,则可能有50个左右。 So, admin tool will load table and column definitions much faster. 因此,管理工具将更快地加载表和列定义。

What you really should be concerned is logic. 您真正应该关心的是逻辑。 Having domains makes sure you don't mismatch some columns' datatypes which could create problems with foreign keys for example. 具有域可确保您不会与某些列的数据类型不匹配,例如,这可能会导致外键出现问题。 Also, it makes easier to change some domain datatype globally: for example, some time ago I decided to change datatype of CustomerIDs in Customer table in one of my databases. 而且,它可以更轻松地全局更改某些域数据类型:例如,前段时间,我决定更改一个数据库中Customer表中CustomerID的数据类型。 It is referenced in about 50 foreign keys. 在大约50个外键中引用了它。 With domains, it was as easy as dumping SQL script and changing the definition of domain. 使用域,就像转储SQL脚本和更改域的定义一样容易。 If there were no domains, I would have to do search&replace on a huge SQL script - which is of course error prone. 如果没有域,我将不得不在庞大的SQL脚本上进行搜索和替换-当然,该脚本容易出错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM