home *** CD-ROM | disk | FTP | other *** search
- // EOSchemaGeneration.h
- // Copyright (c) 1995, NeXT Software, Inc. All rights reserved.
- //
- // Category on EOSQLExpression for generating SQL statement for creating
- // schema objects (tables). Adaptors can override these methods in their
- // implementation of EOSQLExpression to customize the SQL generated.
-
- #import <EOAccess/EOSQLExpression.h>
-
- @interface EOSQLExpression (EOSchemaGeneration)
-
- + (NSArray *)foreignKeyConstraintStatementsForRelationship:(EORelationship *)relationship;
- // default implementation verifies that relationship joins on foreign key
- // of destination and calls
- // prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
-
- + (NSArray *)createTableStatementsForEntityGroup:(NSArray *)entityGroup;
- + (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup;
- + (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup;
- + (NSArray *)primaryKeySupportStatementsForEntityGroup:(NSArray *)entityGroup;
- + (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup:(NSArray *)entityGroup;
- // These methods generate the SQL statements necessary to implement the
- // schema generation feature for one entityGroup. An entityGroup
- // is an array that contains entities which have the same externalNames.
- // For example, an implementation of the createTableStatementsForEntityGroup:
- // method might return an array containing one EOSQLExpression object that
- // holds the necessary SQL to create a table in an RDBMS.
-
- + (NSArray *)createTableStatementsForEntityGroups:(NSArray *)entityGroups;
- + (NSArray *)dropTableStatementsForEntityGroups:(NSArray *)entityGroups;
- + (NSArray *)primaryKeyConstraintStatementsForEntityGroups:(NSArray *)entityGroups;
- + (NSArray *)primaryKeySupportStatementsForEntityGroups:(NSArray *)entityGroups;
- + (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups:(NSArray *)entityGroups;
- // These methods generate all of the SQL statements necessary to implement the
- // schema generation feature for a list of entityGroups. They loop through each
- // of the entityGroups and invoke their more primitive method with each one.
- // Subclasses can override these methods and add SQL statements to precede or
- // follow the statements for the individual groups.
-
- + (void)appendExpression:(EOSQLExpression *)expression toScript:(NSMutableString *)script;
- // Should add expression to executable SQL script. For Oracle and Informix this
- // adds the trailing semi-colon. For Sybase "go" is added.
-
- + (NSString *)schemaCreationScriptForEntities:(NSArray *)entities
- options:(NSDictionary *)options;
- // Returns a full script suitable to create the schema for the
- // given entities, in a form appropriate for the target database.
- // Options are the same as below.
-
- + (NSArray *)schemaCreationStatementsForEntities:(NSArray *)entities
- options:(NSDictionary *)options;
- // Returns an array of EOSQLExpressions suitable to create the schema
- // for the given entities, in a form appropriate for the target database.
- // Options dictionary describes options for creation. Possible values include:
- // createTables: YES/NO [YES]
- // dropTables: YES/NO [YES]
- // createPrimaryKeySupport YES/NO [YES]
- // dropPrimaryKeySupport YES/NO [YES]
- // primaryKeyConstraints: YES/NO [YES]
- // foreignKeyConstraints: YES/NO [NO]
- // indexesForPrimaryKeys: YES/NO [NO]
- // indexesForForeignKeys: YES/NO [NO]
-
-
- - (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute;
- // Assembles an adaptor specific type string suitable for use in a create
- // table statement. Subclassers should override this method for specific behavior.
- // The default implementation does the following:
- // if (precision != 0) typeString generated is "externalType(precision, scale)"
- // else if (width != 0) typeString generated is "externalType(scale)"
- // else typeString generated is "externalType(precision, scale)"
-
- - (NSString *)allowsNullClauseForConstraint:(BOOL)allowsNull;
- // Generates an adaptor specific string for use in a create table statement that
- // indicates whether this column allows null.
-
- - (void)addCreateClauseForAttribute:(EOAttribute *)attribute;
- // Assembles the part of the create table statement for this attribute using the
- // previous two methods.
-
- - (void)prepareConstraintStatementForRelationship:(EORelationship *)relationship
- sourceColumns:(NSArray *)sourceColumns
- destinationColumns:(NSArray *)destinationColumns;
- // Assembles an adaptor specific constraint statement for relationship.
-
- @end
-