Need To See When Record Was Added To Database but Don't Track That - SQLITE - sqlite

I have an immediate need to identify users added to my SQLite database after a specific date, however I don't currently have a field in my table that tracks the date a record is added. Is there any built in functionality for tracking when a record is added to a SQLite database? If so, how would I go about grabbing this data?

Related

I wander if by using ngx.shared.dict, is there any occassion that makes my data overwrite before it can be inserted into mysql?

I am using ngx lua module, but recently, I need my ngx.shared.dict record and insert some file meta into mysql , but when I do that, I keep thinking what if many people visit this uri at same time, is it possible the data changed before it is inserted into database?

Oracle ALL_TABLES.LOGGING clarification

I queried the user_tables view of sys.all_tables and saw a column called LOGGING which is set to either YES or NO. This is an Oracle 11g database. I am not too familiar with the specifics of Oracle databases.
I just want to find out what that parameter does. What kind of logging are we talking about?
I am interested in finding out if there is any connection between this parameter and the CREATED and LAST_MODIFIED fields usually available in Oracle based applications.
Also does this logging parameter also enable logging of data changes (INSERT, UPDATE, DELETE) including old and new values of fields changed?
Appreciate your help folks!
Sort of. The documentation describes the column thusly:
Indicates whether or not changes to the table are logged; NULL for partitioned tables
The relates to the LOGGING clause in the CREATE TABLE statement:
Specify whether the creation of the table and of any indexes required
because of constraints, partition, or LOB storage characteristics will
be logged in the redo log file (LOGGING) or not (NOLOGGING).
This is separately documented, along with a lot more information. Simply put this indicates whether changes made to the table are being logged so that they can be recovered in the event of an instance failure. It is not so you can reference changes; you'll have to use triggers or a materialized view for that.

Need advice on best practice(s) for using databases in my ASP.NET website

I'm building a website that will be used by employees to log work that they've completed. The site contains a page to submit the information, a page to view the information and a page with the employees personal info like name, email, phone, etc. I'm using ASP.NET Membership for authentication. All code will be VB. My questions:
1) ASP.NET Membership only stores the username and email of members. I want to store additional information like first and last name, phone number, etc. Can I just update the tables in the membership database to include this information? Or should I store this information in a separate database? My goal is to populate text boxes on one of the pages with data specific to the user that is currently logged in.
2) The work completed will be stored in another database since it seems logical to keep it separate from membership data. What is the most efficient way to pull and display records from this separate "work" database that are specific to the user who has logged in and been authenticated against the member database?
3) I'm having trouble with the design of tables for the "work" database. Each record stored in the database will represent a days worth of work. However, a number of activities will occur during that day. Each activity will have a type of activity, location and amount of time worked. An employee can complete 1 activity or 100 activities. I assume I'm going to need a table just for the activities and then relate it to the work table. Does this sound correct?
For your first Point i will suggest you to create your own table of User and relate this table with membership user table with guid viz. keep on userid file in your table and relate it with membership table.
Second point will automatically get solved once you will create your own user table, all you need is to relate work and user table(created by you) to fetch the records from work
And at last if you are creating new table for activities how come you will relate it to your work table, again you will have multiple occurrence for record, instead i would suggest do not create another table for activities keep it in work table itself as if you are creating a new table, you will have to provide relationship with work which will result in redundancy.
Hope this helps.

About the GridView control in asp.net

I'm working on a web application, on one page I am inserting records in the database and I want to display the data in a GridView but on a diffrent page. How can I do this?
I know how to display records in a GridView, but I want to know if there are two web pages,
on one page provides the facility to insert the records and U want to display the records in the GridView bit on the second page.
While it is possible to retain the data being inserted without retrieving it from the database, I think it is better to save the data on the first page and retrieve it from the database on the second page.
You can do this by writing inline SQL or a stored procedure. One simple approach would be to pass the resultset into a DataTable and bind a GridView to that.
That does involve more work -- more code and more trips to the database. However, I think it is very useful when performing INSERTs that the web page is updated to display what actually got into the database. Sometimes, this is different from what the user thinks they entered, and they can see the problem immediately.
One question would be how to identify the data that has just been inserted. I can think of several ways to do that. One is to query for all records entered today by the person logged in (which is recorded in the CreatedBy and CreatedDate columns of the database tables). Sort the resultset in descending order of CreatedDate, so that the most recent entries appear at the top of the GridView. Another would be by assigning a batch number to the data entry and retrieving only the data in that batch.
If you really want to hang on to the data entry, you could put it into Session on the first page, and then retrieve it from Session for display on the second page.
Following along the lines of what DOK said, it's also a lot easier to validate data entered by your users in your business logic before you submit it to the database.
Secondly, users can change their minds about data on a webpage frequently. The data on the web could be in an partially-finished state or could have typos or errors in it. If someone else saw this data and believed that it needed to be completed, then you could end up with duplicated entries in the database that would then require reconciliation.
Honestly, your best bet is to use the Session object to hold temporary user data. The MSDN entry for the GridView RowEditing event contains some great source code for this approach. Whenever I have to use GridViews to handle data from the database, I mimic this.
In addition to handling problems with temporary data storage, you can compare the Session object to your database results to determine whether or not new rows have been inserted. This is somewhat costly as it involves overloading the Equals method (and GetHashCode as well, if you follow what Microsoft recommends) and using Equals to iterate over the two collections, comparing the properties of both objects, and determining which records are new based on records that don't exist in your Session object, but do exist in your database object.
It's also worth noting that this approach assumes that you don't delete data from your database, but set the status of a record in your database to "Deleted" -- if that's a boolean field or an sequence of codes you use to describe the state of rows in a table.

How do I save user specific data in an asp.net site?

I just set up user profiles using asp.net 3.5 using wvd.
For each user I would like to store data that they will be updating every day.
For example, every time they go for a run they will update time and distance. I intend to allow them to also look up their history of distance and time from any past date.
My question is, what does the database schema usually look like for such a set up? Currently asp.net set up a db for me when I made user profiles. Do I just add an extra table for every user? Should there be one big table with all users data? How do I relate a user I'd to their specific data? Etc....
I have never done this before so any ideas on how this is usually done would be very helpful. Thank you.
One easy way is to just add a (one) table to aspnetdb database, this table will be used to track your running session data for all the user profiles. Name it RunnerSessions or something similar, add the following columns to the table:
UserID (use this field to store the profile id from ASP.NET)
SessionDate (use this field to store the run session date)
SessionDistance (use this field to record the distance from that particular run session)
It is a good idea to make UserID + SessionDate fields as your primary key for the RunnerSessions table or create another field called SessionID and set it as autonumber.
To relate each profile to a particular record in the RunnerSessions table, you can store the HttpContext.Current.User.Identity.Name in the UserID field mentioned above.
You are asking for a relational database design. As relational database design is an art in itself and heavily depends on a lot of case specific conditions I will not be able to provide you with a ready-to-go schema.
As I never read any online tutorial about this I will also not post a link here. But you should be able to get started by searching for a relational database design (tutorial) in your favourite search engine.
Maybe someone knows about a good tutorial and can post a link?

Resources