9 out of 10 rated this helpful - Rate this topic

Federation Guidelines and Limitations

This topic describes guidelines and limitations for federations in SQL Database. The general guidelines and limitations are covered in the following sections.

Tables

Federations can contain both federated tables and reference tables. Federated tables are tables created using the FEDERATE ON clause, and contain a column that is associated with the distribution key for the containing federation. Reference tables are tables within a federation that were not created using the FEDERATE ON clause, and have no special association with the federation distribution key.

Federated Tables

The syntax for creating a federated table is described in CREATE TABLE (Windows Azure SQL Database). The following is an example of creating a federation named CustomerFederation, and then creating a federated table named Customer. Note that the federation distribution key of cid is associated with the federation table column of CustomerID through the FEDERATE ON clause:

CREATE FEDERATION CustomerFederation(cid BIGINT RANGE)
GO

USE FEDERATION CustomerFederation(cid = 0) WITH RESET, FILTERING=OFF
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customer](
[CustomerID] [bigint] NOT NULL,
[Title] [nvarchar](8) NULL,
[FirstName] [nvarchar](50) NOT NULL,
[MiddleName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NOT NULL,
[Suffix] [nvarchar](10) NULL,
[CompanyName] [nvarchar](128) NULL,
[SalesPerson] [nvarchar](256) NULL,
[EmailAddress] [nvarchar](50) NULL,
[Phone] [nvarchar](25) NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
[CustomerID] ASC
) 
)FEDERATED ON (cid = CustomerID)

The rows within a federated table are automatically distributed across all member databases within a federation. The member that a given row resides in depends on the value of the column that the table is federated on. Each federation member covers a specific range of values for the federation key, and will contain rows where the federated column value is within the range covered by the member.

Federated tables are included in operations such as SPLIT and DROP. For example, performing a SPLIT operation will result in a federation member splitting into two new databases. The rows of any federated table(s) contained within the member will be split also, and the data will reside in the new members after the SPLIT operation completes. This happens automatically and is transparent to any application using the federation.

Federated tables have the following limitations:

  • The federation column of the federated table can only contain data that confirms to the federation member range_low inclusive and range_high exclusive.

  • The data type of the federation column must exactly match the data type that is defined in the federation definition.

  • All unique and clustered indexes on the federated table must contain the federation column. The order in which the federation column appears in the index can be different from the key ordinal in the federation.

  • Federation column values cannot be updated to values outside the federation member range.

  • The federation column cannot be a persisted or non-persisted computed column.

  • Indexed Views are not supported in federation members.

  • Federation columns cannot be NULLable.

  • All foreign key constraints on federated tables need to include the federation column on both the referrer and the referenced tables at the same ordinal in the foreign key. Reference tables cannot have foreign key relationships with federated tables. Federated tables can have foreign key relationships with reference tables without restrictions.

  • You can drop tables created with the FEDERATED ON clause normally. You can also use ALTER TABLE to change all properties of a federated table except federation attributes such as the federation key. To change a reference table into a federated table or a federated table into a reference table, you must create new tables with the desired properties and drop the existing table.

  • When a table is marked with STATISTICS_NORECOMPUTE, federation operations like SPLIT do not invalidate or recalculate statistics. This could cause execution plan issues after repartitioning operations such as SPLIT.

  • Federated members do not support the identity property

  • Federated members do not support the timestamp and rowversion data type.

All general table metadata for federated tables are stored as per reference tables in well-known system tables such as sys.objects. However federation specific properties are stored in sys.federated_table_columns (Windows Azure SQL Database).

Reference Tables

Reference tables are tables created without the FEDERATE ON clause, and are not automatically distributed across all federation members. While reference tables can be replicated across members of a federation manually, there is no automatic replication process.

Reference tables often contain supporting information for queries against federated tables so that you do not have to perform queries against multiple databases. For example, while customer information may be federated and spread across multiple member databases, there is nothing to be gained from federating state and zip code reference information. However you may want to store a copy of the state and zip code information in each federation member so that your queries do not have to span multiple databases.

Spatial Support

Geography and geometry types cannot be used as the data type of the column that a table is federated on; however they can be part of the federated table. There are no other limitations on using spatial data with federations.

After a SPLIT or DROP operation, spatial indexes stay consistent and intact in the destination federation members.

Hierarchy ID

The hierarchy ID type cannot be used as the data type of the column that a table is federated on; however it can be part of the federated table. There are no other limitations on using hierarchy ID with federations.

After a SPLIT or DROP operation, hierarchy ID indexes stay consistent and intact in the destination federation members.

Connecting to Federation Members

Connections to a federation are performed through USE FEDERATION (Windows Azure SQL Database). This command will automatically route the connection to the correct member within a federation, so you are not required to know the physical implementation of the federation, just the distribution key and the range of valid values covered by its data type.

Specifying the federation distribution key and a value will establish a connection to the member database within the federation. The WITH FILTERING value specified then determines the scope of the connection. When filtering is ON, the scope of the connection is set to the value specified, and every query performed using this connection will behave as if it also contains (federated_column = value). This is useful if you only want to return data associated with the specified value. For more information, see USE FEDERATION (Windows Azure SQL Database).

Security Principals

Authentication and authorization to a database containing a federation is accomplished as normal. Logins and users determine connectivity and roles manage the grouping of principals. However all principals within a database that contains a federation are scoped only to the federation root database, and are not automatically applied to federation members.

Instead, federation members have a concept of linked users. When a user is created within a federation member through the CREATE USER (Windows Azure SQL Database) command, if the name specified matches a user contained in the federation root then a link is created to the user within the federation root database. You cannot create users within a member database that are not linked to a user in the federation root.

To support the management of users within a federation member, CREATE USER (Windows Azure SQL Database) and ALTER USER (Windows Azure SQL Database) support a simplified syntax when used within a federation member. This syntax is:

CREATE USER userName
[;]

ALTER USER userName
    WITH <set_item> [ ,…n]
[;]
<set_item> ::=
     NAME = newUserName

Copy Operations

A database copy cannot be performed on a database that contains federations. Creating a federation fails if a database copy operation is active in the database. Database copy cannot be performed on federation members either.

Database Size Quota

Federation operations are not applied to the federation root quota. If the root database exceeds quota, you will still be able to perform SPLIT and DROP operations. If a federation member’s size quota is exceeded, it is still able to participate in SPLIT or DROP operations as long as the destination database’s quota will not be exceeded by the operation.

Connection and Transact-SQL Properties

At the completion of repartitioning operations such as SPLIT and DROP, connections are dropped. This means that connection properties such as SET options, transaction isolation level settings, or variables are also reset. The SPLIT operation creates a new physical database, which means that the following Transact-SQL properties cannot be maintained across SPLIT operations.

 

Transact-SQL SQL Database Support Limitations Support in databases with Federations

Timestamp and rowversion data type

SQL Database may not preserve the uncommitted timestamp and rowversion values of the current database (DBTS) across failovers.

Timestamp and rowversion data type is not supported in federation members.

Timestamp and rowversion related functions such as @@dbts returns values when no timestamp and rowversion exists in a given database.

SYSUTCDATETIME(),SYSDATETIMEOFFSET(),SYSDATETIME(),getdate(), getutcdate()current_timestamp

SQL Database may report timestamp and rowversion from the local machine and may report times that are further in future or in the past across failovers.

Supported with the same constraints across repartitioning operations.

DATABASE_PRINCIPAL_ID()

Principal SIDs are guaranteed to be the same across federation members and federation root for a given principal name. However principal ids may change after a repartitioning operations such as DROP.

IDENTITY property on columns

IDENTITY property is not supported in federation members. Identity related functions such as IDENT_CURRENT, IDENT_SEED, IDENT_INCR, SCOPE_IDENTITY always return null since no identity columns can exist in federation members.

OBJECT_ID and related functions that work with user defined objects; object_id(…), object_name(object_id), type_id(…), type_name(type_id)

Object_id of any object may change for user defined objects after a repartitioning operation such as DROP.

Altering Databases with Federations

All SQL Database options are supported; however changes to the value of an option on the federation root database will not change the option of any federation members.

See Also

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter