-- NutOps.mesa
-- useful database utilities
-- Implemented by: NutOpsImpl
-- Created by: Donahue on: January 20, 1983 3:48 pm
-- last edited by: Donahue, June 1, 1983 3:38 pm
-- Last Edited by: Willie-sue, February 22, 1983 3:44 pm
-- Last Edited by: Cattell, June 6, 1983 4:13 pm

DIRECTORY
DB,
Rope USING [ROPE];

NutOps: CEDAR DEFINITIONS =
BEGIN

OPEN DB, Rope;

-- **********************************************
-- Handy DB routines: implemented by NutOpsImpl.mesa
-- **********************************************

IsSystemDomain:PROC[d: Domain] RETURNS[BOOLEAN];

IsSystemRelation: PROC[r: Relation] RETURNS[BOOLEAN];

AttributesOf: PROC[r: Relation] RETURNS[AttributeList];
-- Returns list of r's attributes

FirstAttributeOf: PROC[r: Relation] RETURNS[Attribute];
-- returns AttributesOf[r].first

EntityValued: PROC [a: Attribute] RETURNS[BOOL];
-- returns TRUE iff the value stored in attribute a should be an entity

GetUniquenessString: PROC[a: Attribute] RETURNS[ROPE];
-- returns the uniqueness of a: Key, OptionalKey, etc., as a printable string

RSetSize: PROC[rs: RelshipSet] RETURNS[INT];
-- returns the length of rs, and does a ReleaseRelshipSet

GetTuples: PROC[e: Entity, a: Attribute] RETURNS [tl: LIST OF Relship];
-- returns all the tuples that reference e via attribute a

GetRelation: PROC[a: Attribute] RETURNS[r: Relation];
-- finds a's relation

GetRefAttributes: PROC[d: Domain] RETURNS[al: LIST OF Attribute];
-- returns all the attributes that can reference an entity from domain d

RemoveAttribute: PROC[a: Attribute, al: AttributeList] RETURNS[AttributeList];
-- destructively removes a from al

AppendAttributes: PROC [al1, al2: AttributeList] RETURNS [al: AttributeList];
-- destructively appends al1 and al2 and returns the result

-- ***********************************************
-- opening segments and transactions for them
-- ***********************************************

SetUpSegment: PROC[ segmentFile: ROPE, seg: Segment,
        readOnly: BOOLTRUE, number: NAT ← 0];

TryRestart: PROC[trans: DB.Transaction];
-- Attempts to re-open an aborted transaction if user confirms.

AtomFromSegment
: PROC[ segR: ROPE ] RETURNS[ ATOM ];

IsLocalName: PROC[ segR: ROPE ] RETURNS[ BOOL ];

END...