Chapter 45 Foreign key keyword – SqlName

Specify an SQL alias for the foreign key.

usage

To override the default SQL names for additional keys, use the following syntax:

ForeignKey keyname(key_props) References pkg.class(ref_index) [ SqlName = alternate_name ];
Copy the code

Where the alternate name is an SQL identifier.

Break down

This keyword allows you to define alternative names for additional keys when referencing through SQL.

The default

If this keyword is omitted, the SQL name for the foreign key is the keyName specified in the foreign key definition.

Chapter 46 Index keyword – Abstract

Specify that the index is abstract.

usage

To specify that the index is abstract, use the following syntax:

Index MyIndex [ Abstract ];
Copy the code

Note: When creating a shard table, an abstract shard key index is automatically generated without definition.

Break down

Abstract indexes are used only for shard tables. They contain no data, so there is no storage (no global index). A shard table has only one abstract index, called a shard key index. The shard key index is intended to be the key that determines the shard in which the row resides.

If an index is defined as abstract, it cannot be accessed or used by methods or SQL. If you mark this index as unique, or try to use it in a primary key, these constraints are ignored.

An IdKey index cannot be defined as an abstract index. Doing so will result in a class compilation error.

You can use this keyword on an existing index to make it abstract. This does not delete any existing data in the index.

The default

The default value for the abstract keyword is false.

Chapter 47 Index keyword – Condition

Defines a conditional index and specifies the conditions that must be met to include a record in the index.

usage

This keyword is used to migrate existing applications to SQL, not new applications.

Chapter 48 Index keyword – CoshardWith

Specifies the name of the class with which this class is sharded.

usage

Until the shard class is fully implemented, it is recommended to create shard tables from SQL, not from the object side. However, if you look at a class generated by creating a shard table, you might see code like this:

/// ShardKey Indicates the index of the shard table, which is automatically generated by the DDL CREATE table statement
Index ShardKey On DeptNum [ Abstract, CoshardWith = User.Department, ShardKey, SqlName = %ShardKey ];
Copy the code

In this case, the current class is shard with the User.department class.