Pages

Friday, November 26, 2010

Primary Key vs Unique Key

Unique Key constraints:

Unique key constraint will provide you a constraint like the column values should retain uniqueness.
It will allow null value in the column.
It will create non-clustered index by default
Any number of unique constraints can be added to a table.

Primary Key:
Primary key will create column data uniqueness in the table.
Primary key will create clustered index by default
Only one primary key can be created for a table
Multiple columns can be consolidated to form a single primary key
It wont allow null values.

Thursday, October 21, 2010

ASP.Net configuration based default timeouts

  1. executionTimeOut : Default value is 110 seconds.
  2. maxRequestLength : Default value is 4096 KB (4 MB).
  3. Session Timeout : Default value is 20 minutes. 
The above two are the configuration of httpRuntime attribute.
Note: If session timeout is less then execution timeout it means when the request finishes its processing meanwhile, the session get’s end which can raise an error.


e.g.
   1: <httpRuntime executionTimeout="43200" maxRequestLength="104856"  />
   2: <sessionState mode="InProc" cookieless="false" timeout="720"/>

Notice, executionTimeout needs to be filled in seconds where as timeout of sessionstate needs minutes as input.

Application Pool also have idle timeout settings which can be useful.

To get application pool in Windows 2003  :
  1. Right click on your website to display properties page
  2. In the 'Home Directory' Tab of properties contains a drop down Application Pool at last most.
  3. You can notice the name, and close screen.
If you are increasing the session timeout greater then 20 you must need to configure the same amount in your Application Pool Settings.

The httpRuntime tag in ASP.NET configuration files lets you determine several behaviors of ASP.NET at the machine or site, including the global value for script timeout. Here's the complete syntax for this tag:


             maxRequestLength="kbytes"
             minFreeThreads="numberOfThreads"
             minLocalRequestFreeThreads="numberOfThreads"
             appRequestQueueLimit="numberOfRequests" 
             useFullyQualifiedRedirectUrl="true|false"  />
executionTimeout is the maximum time an .aspx page can run before timing out. You should extend this value for pages that perform long database queries or remote calls to a Web service. This attribute corresponds to the Server.ScriptTimeout property.

The format of configurations corresponding to each dot net version
.net [4,3.5]

   executionTimeout = "number"
   maxRequestLength = "number"
   requestLengthDiskThreshold = "number"
   useFullyQualifiedRedirectUrl = "[True|False]"
   minFreeThreads = "number"
   minLocalRequestFreeThreads = "number"
   appRequestQueueLimit = "number"
   enableKernelOutputCache = "[True|False]"
   enableVersionHeader = "[True|False]"
   apartmentThreading = "[True|False]"
   requireRootedSaveAsPath = "[True|False]"
   enable = "[True|False]"
   sendCacheControlHeader = "[True|False]"
   shutdownTimeout = "number"
   delayNotificationTimeout = "number"
   waitChangeNotification = "number"
   maxWaitChangeNotification = "number"
   enableHeaderChecking = "[True|False]"
/>

.Net [2,3]

   executionTimeout = "HH:MM:SS"
   maxRequestLength = "number"
   requestLengthDiskThreshold = "number"
   useFullyQualifiedRedirectUrl = "[True|False]"
   minFreeThreads = "number"
   minLocalRequestFreeThreads = "number"
   appRequestQueueLimit = "number"
   enableKernelOutputCache = "[True|False]"
   enableVersionHeader = "[True|False]"
   apartmentThreading = "[True|False]"
   requireRootedSaveAsPath = "[True|False]"
   enable = "[True|False]"
   sendCacheControlHeader = "[True|False]"
   shutdownTimeout = "HH:MM:SS"
   delayNotificationTimeout = "HH:MM:SS"
   waitChangeNotification = "number"
   maxWaitChangeNotification = "number"
   enableHeaderChecking = "[True|False]"
/>

.Net [1.1]


             maxRequestLength="size in kbytes"
             executionTimeout="seconds"
             minFreeThreads="number of threads"
             minFreeLocalRequestFreeThreads="number of threads"
             appRequestQueueLimit="number of requests"
             versionHeader="version string"/>

Wednesday, October 20, 2010

UML Diagrams brief overview


In brief all diagrams are consider to depict the following things
Activity diagrams*- high-level business processes
Class diagrams***- Collection of static model elements
Communication diagrams**- instances of classes, their interrelationships and message flow b/w them
Component diagrams*** – components composing application/system/enterprise.
Composite Structure diagrams***- internal structure of classifiers with their interaction points to other system parts
Deployment diagrams***- Execution architecture of system.
Interaction overview diagrams**- overviews the control flow within system/business process
Object diagrams***- objects and their relationships at a point in time
Package diagrams***- model element organization and dependencies between packages
Sequence diagrams**- sequential logic modeling
State machine diagrams*- object/interaction state and transition between states
Timing diagram**- state/condition change response of classifier instance/role over time in response to external events
Use case diagrams*- actors and their interrelationships.
Classifiers: such as class/component/use case

Selecting the random rows from a database table for each query fired

 MySQL:

SELECT column FROM table
ORDER BY RAND()
LIMIT 1

 PostgreSQL:

SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1

 Microsoft SQL Server:

SELECT TOP 1 column FROM table
ORDER BY NEWID()

 IBM DB2

SELECT column, RAND() as IDX
FROM table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY

Oracle:

SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1

Thursday, October 14, 2010

Drived Class must serializable

While a class is marked serializable and later another class extends the same class then by default everything in the parent class will be with derived class too. But it not means that if parent class is serializable then child not need to implement the serializable interface as parent already have, because the implementing of serializable by parent means all the properties of the parent are serializable in parent as well as in child but as child properties are not marked as serializable so we must specify explicitly the child class methods too as serializable or we need to mark child class to implementing serializable.

Monday, September 20, 2010

Disable right click/text selection in web page

In case its required no one can use right click context menu in browser while opening the page to restrict all the operations possible with context menu commands the the following is the command that will do the job 
 
document.oncontextmenu = function(){return false;}; 
 
In case its also required to restrict the selection of text as if text will be able to selected then hot keys can copy the contents but disabling selection of text can prohibit the copy. So to disable the selection the following will disable text selection.
 
document.onselectstart= function() {return false;};  
And if these commands are written in the javascript code block then the specified features will be enforced after complete page is loaded with javascript block.

Tuesday, August 10, 2010

JavaScript Debugging [Visual Studio]

The various steps to enable java script debugging is as given below:

1. ASP.Net application configuration to enable debugging
    Open the ASP.Net application in Visual Studio and open ‘web.config’ that created with application and find the tag ‘compilation’ in the file. The line may look like as below:

    If debug=”false” then set it to debug=”true” and resulting will look like as below:

    2.    IIS Configuration to support debugging
    Start --> Settings --> Control Panel --> Administrative Tools --> Internet Information Services (IIS)
    --> Expand Web Sites --> Default Web Site --> right click on your web project required to be debugged and select properties --> click Virtual Directory Tab --> click configuration button --> and in the new opened window click Debugging Tab and ensure that two check boxes labeled 1. “Enable Server Side Script Debugging” 2. and “Enable Client Side Script Debugging” to be checked.


    3. Configure Web browser for debugging:
     Open IE and click on menu Tools --> Internet Options --> Advanced Tab --> if ‘Disable Script Debugging (Internet Explorer)’ and Disable Script Debugging (Other)’ check boxes are checked then uncheck those two check boxes and click button OK. (Refer below Screen Shot)



    4.    Attaching ASP.Net process to Visual Studio:
    If application is opened in VS 2003. Then under Tools menu select attach a process and select aspnet process and attach the process to the application.
    If you open the project in VS 2005 or later then it does not require you to explicitly attach the aspnet process. In the JavaScript add a break point where you want to debug and also add a break point in the .vb or .cs code file where the JavaScript function is called.
    Now run the application. The application running will break at the break point within the javascript code as required.

    Features

    The JavaScript debugger presents many standard debugging features. The following list provides a review of some of these features.
    • Breakpoints: Breakpoints allow you to stop code execution at specific points within the source code. JavaScript breakpoints work just like C#/VB breakpoints.
      Breakpoints are set/cleared by clicking to the left of the code within the IDE; by using the Debug menu or by using the Breakpoint Context menu available by right-clicking on the code. In addition, you may create conditional breakpoints to allow you to define conditions for the breakpoint, as well as set up a macro to run or a message to print when the breakpoint is triggered.
      Breakpoints are viewable in the Watch window located by default in the lower left of Visual Studio 2008.
    • Call Stack: The Call Stack tab in the lower right of Visual Studio 2008 allows you to view what is being called when the ASP.NET page is loaded/running.
    • Locals: The Locals tab in the lower left of Visual Studio 2008 allows you to view the values of variables and objects during script execution. Also, you may change the contents of one of the local variables while the page is running.
    • Execute code: The Immediate Window tab in the lower right of Visual Studio 2008 allows you to execute JavaScript code on-the-fly during page execution.
    The Debug drop-down menu within Visual Studio 2008 provides a Windows submenu that allows you to define what windows to display while debugging. For example: Locals, Watch, Call Stack, and Immediate Window.
    The most used feature during debugging is often breakpoints because you can use them to stop code execution and examine the state of variables and objects at that point in the script. Breakpoints provide a number of features (which are available via the Debug drop-down menu during a debugging session) for their use.
    Code execution stops at each breakpoint — unless it is a conditional breakpoint whose condition has not been met. Once the code is halted, you may choose to continue one line at a time or until the next breakpoint is encountered.
    The debugger is actually enabled via the Debug menu in Visual Studio 2008. You go to Debug | Start to begin a debugging session or press [F5]