Public and Private databases out of sync

I have two staff databases. The public one has information like name, department, extension number etc. The private one has this same information with additional info like home address. The private one uses readers fields to keep people away from sensitive data.

The problem I have is with keeping the data synchronized.

I want to run an agent to do the following.

a) If a new document is created in the public database, create a second one in the private system.

b) If a document in the public one is deleted then delete the corresponding one from the private database.

c) Synchronize field changes between the two databases.

Here is the code I have so far which almost sorts out c) but not a) and b).

Sub Initialize

'// 

On Error Goto ErrorHandler

Dim s As New NotesSession

Dim db As NotesDatabase

Dim publicdb As NotesDatabase

Dim docoll As NotesDocumentCollection

Dim doc As NotesDocument

Dim publicdoc As NotesDocument

Dim lookupview As notesview

Dim counter As Long

Set db = s.currentdatabase

Set publicdb = s.getdatabase(db.server,"EPBStaff.nsf")

If Not(publicdb.isopen) Then

	Call publicdb.open("","")

End If



If Not(publicdb.isopen) Then

	Msgbox "Unable to open the public staff list database",64,"Error"

	Goto OKExit

End If



Set docoll = db.alldocuments

Set lookupview = publicdb.getview("Staff Lookup")

counter = 1

Set doc = docoll.getfirstdocument



While Not(doc Is Nothing)

	

	Set publicdoc = lookupview.getdocumentbykey(doc.getitemvalue("Surname")(0) + " " + doc.getitemvalue("FirstName")(0),False)

	If Not(publicdoc Is Nothing) Then

	'If Not(doc Is Nothing) Then

		Call doc.getfirstitem("StaffNo").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("Department").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("JobTitle").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("LineManager").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("Extension").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("Location").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("MobileNo").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("ShortCode").copyitemtodocument(publicdoc,"")

		Call doc.getfirstitem("DirectDialNo").copyitemtodocument(publicdoc,"")

		'Call doc.getfirstitem("Extension").copyitemtodocument(publicdoc,"")

		

		'// add more public fields here

		Call publicdoc.save(True,False)

	End If

	Set doc = docoll.getnextdocument(doc)

	Print "Processed " + Cstr(counter) + " documents"

	counter = counter + 1

Wend





Goto OKExit

ErrorHandler:

Msgbox "Error (" + Cstr(Err) + "): " + Error + " at line " + Cstr(Erl)

Resume OKExit

OKExit:

End Sub

I hope someone can give me a few pointers where to go next.

Subject: How accessed?

How to users access the public and private documents, Notes client and/or web?

Subject: RE: How accessed?

At the moment this we are just using Notes Clients although we may add web later.

Database administrators & the owner of the document can administer this sensitive information. If a user changes address etc they can amend their own record. A user can also choose to publish or hide this information from other users.

At the moment the public database is widely used throughout the company but the private one isn’t. I will give some thought over to a redesign as Bruce suggests, but any other ideas are welcome.

Subject: Public and Private databases out of sync

Would it work for you to redesign the system so that the private db stores only the sensitive fields, the public db does lookups to the private db to retrieve those sensitive data, and the private db’s ACL keeps unauthorized users from retrieving any of the sensitive data?