home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / EOSchemaGeneration.h < prev    next >
Encoding:
Text File  |  1996-09-09  |  4.7 KB  |  87 lines

  1. // EOSchemaGeneration.h
  2. // Copyright (c) 1995, NeXT Software, Inc. All rights reserved. 
  3. //
  4. // Category on EOSQLExpression for generating SQL statement for creating
  5. // schema objects (tables).  Adaptors can override these methods in their
  6. // implementation of EOSQLExpression to customize the SQL generated.
  7.  
  8. #import <EOAccess/EOSQLExpression.h>
  9.  
  10. @interface EOSQLExpression (EOSchemaGeneration)
  11.  
  12. + (NSArray *)foreignKeyConstraintStatementsForRelationship:(EORelationship *)relationship;
  13.     // default implementation verifies that relationship joins on foreign key
  14.     // of destination and calls
  15.     // prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
  16.  
  17. + (NSArray *)createTableStatementsForEntityGroup:(NSArray *)entityGroup;
  18. + (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup;
  19. + (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup;
  20. + (NSArray *)primaryKeySupportStatementsForEntityGroup:(NSArray *)entityGroup;
  21. + (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup:(NSArray *)entityGroup;
  22.     // These methods generate the SQL statements necessary to implement the
  23.     // schema generation feature for one entityGroup. An entityGroup
  24.     // is an array that contains entities which have the same externalNames.
  25.     // For example, an implementation of the createTableStatementsForEntityGroup:
  26.     // method might return an array containing one EOSQLExpression object that
  27.     // holds the necessary SQL to create a table in an RDBMS.
  28.  
  29. + (NSArray *)createTableStatementsForEntityGroups:(NSArray *)entityGroups;
  30. + (NSArray *)dropTableStatementsForEntityGroups:(NSArray *)entityGroups;
  31. + (NSArray *)primaryKeyConstraintStatementsForEntityGroups:(NSArray *)entityGroups;
  32. + (NSArray *)primaryKeySupportStatementsForEntityGroups:(NSArray *)entityGroups;
  33. + (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups:(NSArray *)entityGroups;
  34.     // These methods generate all of the SQL statements necessary to implement the
  35.     // schema generation feature for a list of entityGroups. They loop through each
  36.     // of the entityGroups and invoke their more primitive method with each one.
  37.     // Subclasses can override these methods and add SQL statements to precede or
  38.     // follow the statements for the individual groups.
  39.  
  40. + (void)appendExpression:(EOSQLExpression *)expression toScript:(NSMutableString *)script;
  41.     // Should add expression to executable SQL script.  For Oracle and Informix this
  42.     // adds the trailing semi-colon.  For Sybase "go" is added.
  43.  
  44. + (NSString *)schemaCreationScriptForEntities:(NSArray *)entities
  45.                                             options:(NSDictionary *)options;
  46.     // Returns a full script suitable to create the schema for the
  47.     // given entities, in a form appropriate for the target database.
  48.     // Options are the same as below.
  49.  
  50. + (NSArray *)schemaCreationStatementsForEntities:(NSArray *)entities
  51.                                             options:(NSDictionary *)options;
  52.     // Returns an array of EOSQLExpressions suitable to create the schema
  53.     // for the given entities, in a form appropriate for the target database.
  54.     // Options dictionary describes options for creation.  Possible values include:
  55.     //    createTables:            YES/NO [YES]
  56.     //    dropTables:              YES/NO [YES]
  57.     //    createPrimaryKeySupport  YES/NO [YES]
  58.     //    dropPrimaryKeySupport    YES/NO [YES]
  59.     //    primaryKeyConstraints:   YES/NO [YES]
  60.     //    foreignKeyConstraints:   YES/NO [NO]
  61.     //    indexesForPrimaryKeys:   YES/NO [NO]
  62.     //    indexesForForeignKeys:   YES/NO [NO]
  63.  
  64.  
  65. - (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute;
  66.     // Assembles an adaptor specific type string suitable for use in a create
  67.     // table statement. Subclassers should override this method for specific behavior.
  68.     // The default implementation does the following:
  69.     //         if (precision != 0) typeString generated is "externalType(precision, scale)"
  70.     //         else if (width != 0) typeString generated is "externalType(scale)"
  71.     //        else typeString generated is "externalType(precision, scale)"
  72.  
  73. - (NSString *)allowsNullClauseForConstraint:(BOOL)allowsNull;
  74.     // Generates an adaptor specific string for use in a create table statement that
  75.     // indicates whether this column allows null.
  76.  
  77. - (void)addCreateClauseForAttribute:(EOAttribute *)attribute;
  78.     // Assembles the part of the create table statement for this attribute using the
  79.     // previous two methods.
  80.  
  81. - (void)prepareConstraintStatementForRelationship:(EORelationship *)relationship
  82.          sourceColumns:(NSArray *)sourceColumns
  83.          destinationColumns:(NSArray *)destinationColumns;
  84.     // Assembles an adaptor specific constraint statement for relationship.
  85.  
  86. @end
  87.