public static UniqueConstraint primaryKeyOf(Attribute att) { UniqueConstraint.Builder builder = new UniqueConstraint.Builder((DatabaseRelationDefinition)att.getRelation()); return builder.add(att).build("PK_" + att.getRelation().getID().getTableName(), true); }
private static String extractPredicateName(RelationDefinition r) { RelationID id = r.getID(); String name = id.getSchemaName(); if (name == null) name = id.getTableName(); else name = name + "." + id.getTableName(); return name; }
private static List<Attribute> getIdentifyingAttributes(DatabaseRelationDefinition table) { UniqueConstraint pk = table.getPrimaryKey(); if (pk != null) return pk.getAttributes(); else return table.getAttributes(); }
/** * creates a single-attribute foreign key * * @param name * @param attribute * @param reference * @return */ public static ForeignKeyConstraint of(String name, Attribute attribute, Attribute reference) { return new Builder((DatabaseRelationDefinition)attribute.getRelation(), (DatabaseRelationDefinition)reference.getRelation()) .add(attribute, reference).build(name); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof QualifiedAttributeID) { QualifiedAttributeID other = (QualifiedAttributeID)obj; return (this.attribute.equals(other.attribute) && ((this.relation == other.relation) || ((this.relation != null) && this.relation.equals(other.relation)))); } return false; }
/** * creates relation id from the database record (as though it is quoted) * * @param schema as is in DB (possibly null) * @param table as is in DB * @return */ public static RelationID createRelationIdFromDatabaseRecord(QuotedIDFactory idfac, String schema, String table) { // both IDs are as though they are quoted -- DB stores names as is return new RelationID(QuotedID.createIdFromDatabaseRecord(idfac, schema), QuotedID.createIdFromDatabaseRecord(idfac, table)); }
/** * creates attribute ID from the database record (as though it is a quoted name) * * @param s * @return */ public static QuotedID createIdFromDatabaseRecord(QuotedIDFactory idfac, String s) { // ID is as though it is quoted -- DB stores names as is return new QuotedID(s, idfac.getIDQuotationString()); }
@Override public RelationID createRelationID(String schema, String table) { return new RelationID(createFromString(schema), createFromString(table)); }
@Override public RelationID createRelationID(String schema, String table) { return new RelationID(createFromString(schema), createFromString(table)); }
public static BasicDBMetadata createDummyMetadata() { return new BasicDBMetadata("dummy", null, null, "", new QuotedIDFactoryStandardSQL("\"")); } }
@Override public RelationID createRelationID(String schema, String table) { return new RelationID(createFromString(schema), createFromString(table)); }
public static UniqueConstraint primaryKeyOf(Attribute att, Attribute att2) { UniqueConstraint.Builder builder = new UniqueConstraint.Builder((DatabaseRelationDefinition)att.getRelation()); return builder.add(att).add(att2).build("PK_" + att.getRelation().getID().getTableName(), true); }
private static String extractPredicateName(RelationDefinition r) { RelationID id = r.getID(); String name = id.getSchemaName(); if (name == null) name = id.getTableName(); else name = name + "." + id.getTableName(); return name; }
private static List<Attribute> getIdentifyingAttributes(DatabaseRelationDefinition table) { UniqueConstraint pk = table.getPrimaryKey(); if (pk != null) return pk.getAttributes(); else return table.getAttributes(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof QualifiedAttributeID) { QualifiedAttributeID other = (QualifiedAttributeID)obj; return (this.attribute.equals(other.attribute) && ((this.relation == other.relation) || ((this.relation != null) && this.relation.equals(other.relation)))); } return false; }
/** * creates relation id from the database record (as though it is quoted) * * @param schema as is in DB (possibly null) * @param table as is in DB * @return */ public static RelationID createRelationIdFromDatabaseRecord(QuotedIDFactory idfac, String schema, String table) { // both IDs are as though they are quoted -- DB stores names as is return new RelationID(QuotedID.createIdFromDatabaseRecord(idfac, schema), QuotedID.createIdFromDatabaseRecord(idfac, table)); }
/** * creates attribute ID from the database record (as though it is a quoted name) * * @param s * @return */ public static QuotedID createIdFromDatabaseRecord(QuotedIDFactory idfac, String s) { // ID is as though it is quoted -- DB stores names as is return new QuotedID(s, idfac.getIDQuotationString()); }
@Override public RelationID createRelationID(String schema, String table) { return new RelationID(createFromString(schema), createFromString(table)); }
public static UniqueConstraint primaryKeyOf(Attribute att) { UniqueConstraint.Builder builder = new UniqueConstraint.Builder((DatabaseRelationDefinition)att.getRelation()); return builder.add(att).build("PK_" + att.getRelation().getID().getTableName(), true); }
public static UniqueConstraint primaryKeyOf(Attribute att, Attribute att2) { UniqueConstraint.Builder builder = new UniqueConstraint.Builder((DatabaseRelationDefinition)att.getRelation()); return builder.add(att).add(att2).build("PK_" + att.getRelation().getID().getTableName(), true); }