             ))
             
             for iri in iris {
-                try db.run(termsTable.insert(
-                    termTypeColumn <- TermType.iri.rawValue,
-                    termValueColumn <- iri
-                ))
+                let _ = try getOrSetID(for: Term(iri: iri))
             }
         }
     }

        }
    }
    
    internal func term(for id: TermID) -> Term? {
        if let t = i2tcache[id] {
            return t
        }
        
        let query = termsTable.select(termsTable[*]).filter(idColumn == id)
        do {
            guard let row = try db.pluck(query) else {
                return nil
            }
            guard let t = term(from: row, typeColumn: termTypeColumn, valueColumn: termValueColumn, languageColumn: termLangColumn, datatypeColumn: termDatatypeColumn) else {
                return nil
            }
            i2tcache[id] = t
            return t
        } catch {}
        return nil
    }
    
    public func makeIterator() -> AnyIterator<Quad> {
        let query = quadsTable.select(quadsTable[*])

//        db.trace {
//            print("[TRACE] \($0)")
//        }
        next = (iri: 0, blank: 0, datatype: 0, language: 0)
        i2tcache = LRUCache(capacity: 1024)
        t2icache = LRUCache(capacity: 1024)
        try initializeTables()
