473,383 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to identify a user of concurrent users in centralized sql server database

Dear Friends,
We are developing an inventory maintenance project in C#.net 2005 with MSDE as back end.Data can be accessed by multiuser at the same time, because they are from a single centralized database.
Now, we are planning to implement audit trail to track which record is manipulated by which user.
Jan 20 '08 #1
8 2647
ck9663
2,878 Expert 2GB
Dear Friends,
We are developing an inventory maintenance project in C#.net 2005 with MSDE as back end.Data can be accessed by multiuser at the same time, because they are from a single centralized database.
Now, we are planning to implement audit trail to track which record is manipulated by which user.
depending on some factors. your authentication method, your system design, your entire system architecture...

you can use the system_user, user_name() system variable and function, you can either create a stored proc that update your audit table...or create a trigger that update your audit table every time there's an update on your transaction table...or if you create a before and after update record on your transaction table, you can just add an UpdatedBy field and update it everytime..

-- CK
Jan 20 '08 #2
Thank You CK.I thought ,As you say ,It is good to have "UpdatedBy" field in every tables which are going to be audited.Before implementing this, I am having doubt,
Is it possible to pass argument to a trigger which will resolve this problem with less effort from client program?.please advice me.
Jan 22 '08 #3
ck9663
2,878 Expert 2GB
Thank You CK.I thought ,As you say ,It is good to have "UpdatedBy" field in every tables which are going to be audited.Before implementing this, I am having doubt,
Is it possible to pass argument to a trigger which will resolve this problem with less effort from client program?.please advice me.
I don't think you can. But there could be other ways of doing it. What argument are you trying to pass and what is it for?

-- ck
Jan 22 '08 #4
Thank you CK for your helps.
I am thinking of passing log in user name (which is in "Employee" table) as argument.with this, we can insert the audit log which record is manipulated by which user.How to we accomplish this through triggers/any other T-SQL code ?

Thanks,
Preethi
Jan 23 '08 #5
ck9663
2,878 Expert 2GB
Thank you CK for your helps.
I am thinking of passing log in user name (which is in "Employee" table) as argument.with this, we can insert the audit log which record is manipulated by which user.How to we accomplish this through triggers/any other T-SQL code ?

Thanks,
Preethi
so the login profile (username, password) is on the Employee table? i would assume you're using some sort of front-end application. you can keep the employeeid on the application side. during insert, you have call a stored procedure that grabs other info on your employee table that you want inserted on your transaction table, then you do the insert..

or........

you can actually create an updatable view. and update all the table as necessary.

-- ck
Jan 23 '08 #6
Hi CK,
You are right in that I am using Front-End application which holds logged user details.I Could not understand the "Updateable View" concept.Could you explain it for me to implement audit-log.

Thanks with Anticipation,
Preethi
Jan 23 '08 #7
ck9663
2,878 Expert 2GB
Hi CK,
You are right in that I am using Front-End application which holds logged user details.I Could not understand the "Updateable View" concept.Could you explain it for me to implement audit-log.

Thanks with Anticipation,
Preethi

options 1:
1. create an RecordStat, UpdatedBy, UpdatedOn columns on your table.
2. get all the value of the fields of the table you are updating.
3. instead of issuing an UPDATE statement on the updated field, just update RECORDSTAT = 'I' (or 0 or whatever value you like to signify that the status of the record is inactive). this can also be done if the user delete the record from the GUI
4. on your update statement, build it in such a way that it will be a combination of values from your variable and from your GUI. the value from your variable are those you gather from #2 (above). the value from your GUI are those that your user updated.however for Recordstat = 'A', UpdatedBy = ValueFromYourGUIThatHoldsUserLoggedInfo, UpdatedOn = systemdate(). you will now have an almost duplicate record. with the exception of the fields that were updated and the 3 new fields.
5. In all your query, you have to be conscious that only active records has to be chosen. this means you have to add WHERE RECORDSTAT = 'A' on all your query.

challenge: a user can go to sql analyzer and mess up your table and no audit will be done


option 2:
1. create an RecordStat, UpdatedBy, UpdatedOn columns on your table.
2. create an update trigger on your table
2.a. when update trigger fires, insert the entire deleted table on your table with the exception of RecordStat values of these fields should be RecordStat = 'I'.
3. you should have an almost identical record with the exception of the three fields.
4. In all your query, you have to be conscious that only active records has to be chosen. this means you have to add WHERE RECORDSTAT = 'A' on all your query.

challenge: lot of programming work; disk space (but storage are cheap)


option 3:
1. create an update and delete trigger on your table.
2. when update or delete trigger fires, insert the deleted table into a "dump" table where you dump all updates and deletes. before inserting, make sure to capture the UpdatedBy and UpdatedOn values.
3. this way, you don't change any other queries, you keep your table as is, and you have the audit somewhere else. you can use the audit table for analysis

challenge: lot of programming work; disk space (but storage are cheap); your table is not really complete and has to be split into two


it would all depend on how big your table is. this could all be fine if you have small size. for bigger (read: million-s), try option 3. try all and check for performance.

views
triggers

hope that make sense :)

-- ck
Jan 23 '08 #8
Thank You to you CK for spending your valuable time for me. I am trying to implement the third option with triggers and updated field and ask your help if I needed.

With Thanks ,
Preethi.
Jan 24 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
3
by: canigou9 (remove your socks to reply) | last post by:
(cross posted - comp.databases.ms-access, microsoft.public.access) Hello folks - this is my first post here, after a short lurk. I have written an application in Access2002 for a friend's...
8
by: pnp | last post by:
Hi all, I've developed a win C# app that is actually database driven using SQL server 2000. The idea is that only one application will be installed on a server in a network and the program will be...
2
by: flat_ross | last post by:
Hi, I am in a shop where developers are required to work off of a network share. This is so that code is backed up nightly. So I am testing running an ASP.NET Web application with a Class...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
2
by: Cincin | last post by:
We were building this forum application and we stumble on how to identify unread post. One thing would be to keep in the database what an user have seen but it doesn't seem doable because of the...
4
by: Peppie | last post by:
I have a (self proclaimed ) very nice and well designed database that organizes my clients, contacts, projects and documents sent to my clients (including a report generator in MS Word). At...
6
by: goraya | last post by:
This is design level discussion about web applications. How I design application that support 1 million concurrent requests??
2
by: mktselvan | last post by:
Hi, Existing running oracle application 11i (11.5.8) Database version is 8.1.7.4 There is any command / way to know the number of concurrent users for this application. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.