XCode best practices: Best Data Types

Source: Internet
Author: User
Tags time and date

Compared with other ORM frameworks, XCode has the strongest multi-database forward and reverse engineering, and has not found any more powerful than XCode yet. Haha!

However, XCode's multi-database reverse engineering is also costly. The data types of different databases differ by 108,000, which is not fully supported.
Therefore, we only support common data types, but these are enough to meet the 99% requirements.

The optimal data types are as follows:
1, integer. Int32 is a standard configuration, which is mandatory. In Oracle, an integer is Numeric with a decimal number of 0.
2, long integer. Int64, most databases do.
3, short integer. Int16, this should be careful. It seems that some databases are not supported. If not, XCode will automatically select Int32, so do not save the storage space.
4. boolean. Boolean is supported by most databases. MySql does not. It is generally implemented using an enumeration Y/N. XCode supports this.
5. Floating Point Number. Single-precision Fload Double-precision Double is recommended, otherwise it is difficult to unify different databases, there are tens of millions of careful precision settings and decimal places, XCode reverse engineering may not be able to migrate the precision and decimal places perfectly to other types of databases, and there is no problem with the same type.
6. Currency. Decimal, which is required for the currency type and corresponds to the Money of MSSQL. Be careful when developing. Do not use Decimal to determine whether the two values are equal. subtract from each other to determine whether the difference is less than 0.000001. This Decimal number depends on the situation.
7. time and date. DateTime. All databases use DateTime, which does not support migration of individual Date or Time. This type is the most painful type in XCode. A separate Date and Time cannot be compatible with different types of databases.
8, String. String, nvarchar is used in all MSSQL statements, and Unicode becomes longer. The string type is the only one that supports the length of different database settings. All of the above types are not supported completely.
9. Large text. String. ntext is used in all MSSQL statements. In. Net, it is the same as a String. It is identified as nvarchar or ntext based on the maximum length of strings in different databases (MSSQL is 4000.

Best experience:
1. Single primary key. We recommend using auto-incremental ID. XCode supports data migration of auto-increment fields. Of course, if you need to merge data, You have to process the logic yourself.
2. Create various indexes.

Worst experience:
0 and zero are the worst. XCode does not support null Types. Therefore, do not make null and "" have different business meanings. default values of various types indicate invalid data.
1. Except for the string length, other types are absolutely absolute. Do not set other attributes, including length, precision, and decimal places. Otherwise, XCode cannot achieve perfect migration.
2. XCode currently does not support foreign keys for various databases. The newly added relationship between tables is obtained through speculation. Rule: when the field name is equal to another table name and the primary key name, it is considered as a foreign key.
3. Do not use the Guid and binary types. XCode only supports forward engineering and does not support reverse engineering. Replace Guid with nvarchar (32)
4. Try not to use varchar/char for strings, because different databases and even different versions of the same database have great differences. This saves a lot of space.
5. Do not use the default value whenever possible. At present, only the default value of the current time can be better supported, and newid () also has simple support. This is too painful and may not be supported in the future.

No type ing table exists in XCode. Don't guess it !!!
ADO. net architecture has a PES ypes mode, which XCode uses. Therefore, what field types correspond. net type is determined by various database drivers, not XCode, so we do not know whether all types are supported.
It is enough for us to use these types for so many years.

 

 

The last sentence is:

We only do the most common 80% daily work. What are the special situations and try our best!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.