In thinking of a TYPE collection as a database, I began to see the wonderful power of Types. Then I thought to myself: "wouldn't it be really cool if one could use SQL?" Using ID 'Keys' one can link information of one Type to another very similar to Primary/Foriegn Keys used in Relational Databases.
Just for thought.
Example: Type Employee Field ID% Field LastName$ Field FirstName$ Field Position$ End Type Type Project Field ID% Field Name% End Type Type Work Field EmployeeID% Field ProjectID% Field HoursWorked% End TypeNow the current dilema is Random Access to Blitz Types cause their designed for Sequential Access using BEFORE, AFTER, and FOR ... EACH Commands. However, the problem is easily resolved by using a Array Of Types.
Example: Dim EmployeeID.Employee(100)With a lil more code one could quickly create a means of assigning Keys to a Type Instance and storing the type in the array for instant access.
Example: Function EmployeeNew.Employee(ID) this.Employee = New Employee this\ID=ID EmployeeID(ID)=this Return this End FunctionAn Array Of Types would be used for each Type Collection (Records). One can devise various systems to assign IDs. This method provides an easily means link different Types together by ID Keys.
Example: Employee.Employee=EmployeeNew(1) ;New Employee Record #1; Employee\LastName = "Taylor" Employee\FirstName = "Frank" Project.Project=ProjectNew(7) ;New Project Record #7; Project\Name$="SQL For Types" Work.Work = WorkNew(619) ;New Work Record #619; Work\EmployeeID= 1 Work\ProjectID = 7 Work\HoursWorked = 8Now heres were SQL could come into play. Instead of using FOR..EACH to access and assign data to the collection, you could Query the collection and manipulate data that meets the conditions.
Example: SELECT EmployeeID FROM ActiveWork.Work WHERE EmployeeID = 1 Employee.Employee=EmployeeID(ActiveWork\EmployeeID) Employee\Position = "Promotion To Lead" END SELECTBlitz already provides a native means to UPDATE, INSERT, and DELETE records from the collection. So now all that is needed is a means to Sort by Conditions. Most of the SQL Commands could be used: ORDER BY, IN, BETWEEN, JOIN, UNION, CREATE, DROP, ALTER, GROUP BY, INTO.
Just for thought.