Pages

May 27, 2011

Interview Questions: What is the difference between unique-key and primary-key in database (Oracle , Microsoft SQL Server, Access , MySQL etc)

Interview Questions: What is the difference between unique-key and primary-key in database (Oracle , Microsoft SQL Server, Access , MySQL etc...)

This is a mature question , I myself had faced this question in an interview but couldn't describe all the points but I was able to describe the main key point of this question "What is the difference between unique-key and primary-key in database".


The main key points of this question( "What is the difference between unique-key and primary-key in database") is below number 1,2.


1) Unique key (UK) can be null but Primary key can't be null.
2) Primary key (PK) can be referenced to other Data-tables as a Foreign(FK) but 

Unique key (UK) can't play this role.

3) We can have multiple unique keys(UK) in a table but in the case of Primary key (PK) there should be only one.
4) And also a primary key creates a cluster-index by default but unique key creates a non-cluster-index by default.


More Explanation: 
Primary Key is a combination of Unique and NOT NULL Constraints so it can’t have duplicate values or any null values.
Moreover in Oracle Databases,  UNIQUE Key Columns can have any number of NULL values, however in MS SQL Server/ Microsoft-Access can only have one NULL value in  their unique key column.

What is Foreign Key:

Related links in What is the difference between unique-key and primary-key:

SEO Labels:

Uniquekey and primarykey Difference , 

What is the difference between unique-key and primary-key , 

Interview Questions: What is the difference between unique-key and primary-key , 

Foreign ,Key, Primary ,Key, Unique, Key

May 19, 2011

Alim Ul Karim's Blog: How to Create Database First in ASP.NET MVC3/MVC 3...

Alim Ul Karim's Blog: How to Create Database First in ASP.NET MVC3/MVC 3...: "If you are new in ASP . NET MVC / MVC3 or in EntityFramework ( EF ) you should look for some articles before read this topic. If you ar..."

How to Create Database First in ASP.NET MVC3/MVC 3 using Entity Framework (EntityFramework - EF 4.1/EF4.1) 4.1

If you are new in ASP.NET MVC /MVC3 or in EntityFramework (EF) you should look for some articles before read this topic. If you are a beginner or apprentice then , I suggest you to watch Scott Hanselman's MVC-101 video , it will help you to learn about new ASP.NET 4 MVC3 from beginner to advanced (if MVC2 is already known to you ,  MVC3 will not be a new path or unknown to you , basic structure remain same as MVC2).


The reason behind I am writing this topic because I haven't found any good resource to start my project as Database First in MVC using Entity Framework 4.1 (EF 4.1). In Entity Framework 4.1 coders,database designers, model designers can do what they want first, if you like to code then code first (there are lots of examples over the internet  about - code first in EF 4.1 few of them are linked in my article), if like to create model first then do it first and so on.
In this topic, I will write less and help you via images because  it's a fast and easy way to learn. So let's begin to work.


I have created a new ASP.NET 4 MVC3 HTML5 based Internet application, attached a database first as shown in the image , I recommend you to download the source and investigate yourself.
Project First Appearence - Database DB First Approach ASP.NET 4 MVC3
BlogContent DataTable Data
Taxonomy Data
ContentType Table Data
Existing Database , table relationships schema - Database DB First approach


Creating ADO.NET ENTITY Data Model From a Existing Database - Database First Approch


Generate Entity Data Model From Existing Database - DB - Database DB First approach 

Creating ConnectionString from Exiting Database - Database First approach


Entity Data Model Edmx file view


 right click on the white surface in the entity data model of Blog Database.

DBContext Generate From Entity Data Model

Creating Repository , Model and Database Table Class from the Entity Data Model, Click on 'ok' twice
Now Build your project and then do as below.
After Creating Repository, Model and DBContext from Wizard


Controller Wizard to Create V-View, C- Controller
V-View and C- Controller has been created with Read,Write, Delete, Details View ability

Created a Link for the Blog Content Controller

Preview of the Project

Code : http://www.mediafire.com/download/4oai056o5h3enlr/WebApplication3.7z


Download the Source File:
  1. Direct Link: Blog OpenSource Project - Database First Approch - ASP.NET MVC3 HTML5 Project
  2. Mediafire Link: Blog OpenSource Project - Database First Approch - ASP.NET MVC3 HTML5 Project
Related Videos of Scott Hanselman, Steve Sanderson , download High WMV for best quality experience:
  1. Scaffolding – ASP.NET, NuGet, Entity Framework Code First and More
  2. DevDays Keynote + MVC-101 + Nuget : Depth
  3. NuGet In Depth: Empowering Open Source on the .NET Platform

Author Related Links:
SEO Labels:

DB First Approch / Database First Approch / Create Database First then model then code / First effort Database - DB ASP.NET MVC 3/ MVC3 / EntityFramework Database First / EF 4.1 / EF4.1 Database First approch / EF 4.1 Database(DB) First Approch .

May 3, 2011

Adobe Flash CS3,CS4,CS5 (ActionScript 3.0 AS3) - Video/MovieClip/MC/Movie Clip - FLV/SWF - sound/audio volume decreasing or increasing or mute or reduce code. -- How to sound off in a flash movieclip as3


Adobe Flash CS3,CS4,CS5 (ActionScript 3.0 AS3) - Video/MovieClip/MC/Movie Clip - FLV/SWF - sound/audio volume decreasing or increasing or mute or reduce code.


Over the Internet, I had searched a lot and found few articles that suggested me to add soundclips as an external object and then control or reduce it(volume/sound) but what if  I have a video.swf or flv which contains sound/audio in my library or in the stage and I want to reduce or increase it's volume/sound.After , searching for 5 hours I was bored but finally found the solution  and now I want to share it with everyone.


So no more talk , just read the code and you will have the idea how to do it.


Code:
//Suppose I have a movieclip/mc/movie clip named 'video' which contains audio and video entity 
// we are writting as3/actionscript 3.0 coding , follow as below.


//Mute Volume/Sound
video.soundTransform = new SoundTransform(0);  //maybe it won't work in AS2/ActionScript 2.0...works in as3



//Full Volume/Sound
video.soundTransform  = new SoundTransform(1);  //maybe it won't work in AS2/ActionScript 2.0...works in as3


//Half Volume/Sound
video.soundTransform = new SoundTransform(.5);  //maybe it won't work in AS2/ActionScript 2.0...works in as3




SEO Tags:


Flash ,

Flash Sound off ,

Flash Sound Reduce from Original ,

Flash Sound Reduce in a movieclip ,

Flash AS3 Sound Reduce in a movieclip ,

Flash AS3 Sound Reduce in a movieclip ,

Flash AS3 Sound Mute in a movieclip ,

Flash AS3 Sound Mute in a flv file ,

Flash AS3 Sound Reduce in a movieclip ,

Flash AS3 Sound Reduce in a flv file ,

Flash AS3 Sound Reduce in a movie file ,

Flash AS3 Sound Sound off flv file ,

Flash AS3 Sound SoundOff in movieclip ,

Soundoff




Adobe Flash CS3,CS4,CS5 (ActionScript 3.0 AS3) - Send Data (SendData) to a URL or PHP or ASP Page as Post or Get Method Example

Adobe Flash CS3,CS4,CS5 (ActionScript 3.0 AS3) - Send Data (SendData) to a URL or PHP or ASP Page as Post or Get Method Example
by using this method we can send email to our clients.


Tested on Flash ActionScript 3.0(AS3) - 

function send_data_to_url():void
{
var url_var:URLVariables = new URLVariables();
url_var.email = "auk.junk@live.com";

 url_var.first_name      = "Alim";
 url_var.middle_name   = "Ul";
 url_var.last_name           = "Karim"; //Alim Blog
 url_var.blog             = "Blog";
 //add as much as you want.
 trace(url_var);

sendData("example.php",url_var); //or use asp page url

}

function sendData(url:String, _vars:URLVariables):void
{
var request:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
request.data = _vars;
request.method = URLRequestMethod.POST; //Set Get Method if you want
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.load(request);

}
function handleComplete(event:Event):void
{
var loader:URLLoader = URLLoader(event.target); // send request complete , you can do   what ever you want
}
function onIOError(event:IOErrorEvent):void
{
//a.text = "Error loading URL."; // print error in a textfield
}


Tags:

Flash ActionScript,

SendData,

to url,

ASP ,

PHP,AS3

Mar 10, 2011

Few Question & Answers About .Net Framework - Part 1

Explain the .Net Framework.

The .Net framework allows infrastructural services to all the applications developed in .net compliant language. It is an engine that provides runtime services using its component like Common Runtime Language. It consists of two main components such as Common Language Runtime and Framework Class Library.

Describe the .Net Framework Architecture. 

The .Net Framework has two main components:
.Net Framework Class Library: It provides common types such as data types and object types that can be shared by all .Net compliant language.

The Common language Runtime: It provides services like code execution, type safety, security, thread management, interoperability services.
 

What are the components of the .Net Framework?

Class Loader, Compiler, Garbage Collection, Type checker, Debug engine, Exception Manager, Security engine, Thread manager, COM Marshallar, Class Library.

Explain the role of assembly in the .Net Framework.

.Net Framework keeps executable code or DLL in the form of assembly. .Net Framework maintains multiple versions of the application in the system through assembly. The assemblies have MSIL code and manifest that contains metadata. The metadata contains version information of the assembly.

Describe the GAC in the .Net Framework. 

.Net Framework provides Global Assembly cache, a machine-wide cache. It stores shared assemblies that can be accessed by multiple languages.

Explain the Debug class methods.

a. Assert:This method checks for a condition. It displays a user message if the condition is false.
b. Write:used to write information which will be used by Trace Listeners.
c. WriteIf:Write information for Trace Listeners only if the condition is true.
d. WriteLine: same as write but, every time writes in a new line.
e. WriteLineIf:same as WriteIf but everytime writes in a new line.

Explain the methods of windows-based authentication

Anonymous authentication gives access to read-only areas of the Web site which do not need any username and password.

Basic Authentication It is done through IIS. This is based on the windows user accounts. When using Basic authentication, the browser lets the user to enter the username and password.
Digest authentication allows sending hash or digesting over the network rather than the plain text as in the case of basic authentication.
Integrated Windows authentication- It is based on users having Windows domain accounts. This type of authentication prevents from pasing the password across the network. It is considered to be the best authentication system over intranet.

What are the ways to optimize the performance of a windows application?

a. Knowing when to use StringBuilder
b. Comparing Non-Case-Sensitive Strings
c. Use string.Empty
d. Replace ArrayList with List<>
e. Use && and || operators
f. Smart Try-Catch
g. Replace Divisions
h. Code profiling
i. Use performance monitor to observe counters written in the application

Explain the key events in the lifecycle of the form.

a. Load: fired when form is first loaded in the application
b. Activated: fired whenever the form gets the focus i.e. when loaded first time, restored from the minimize state, whenever the form is brought in front.
c. Deactivated: fired whenever the form looses focus i.e. when form is closed, minimized, when it is in background.
d. Closing: Triggered when application wishes to be closed.
e. Closed: Triggered when application is closed.
f. Disposed: Used for garbage collection. 

Explain all the windows that help with your debugging.

Call stack: This window provides a description for the flow of application till the current line where the debugger is pointing to. It gives the page information, method name, arguments, line number etc.
Locals: This window provides access and information about all the local variables available at current line. One can see the values of all the local variables/values available at the current line.
Watch: This window has a list of variables that are of interest to the developer. The developer explicitly adds watch to the variables that he is interested in and they all are listed in this window for observation.
Immediate: Immediate window is like a live application paradigm. One can write code in this and see the values that are returned on the basis of current execution of the application. Breakpoints: This window lists all the lines of codes that have a breakpoint and the condition when it will be hit. It also gives the count representing the number of times that breakpoint has been hit.
Output: this window gives a description of assemblies and code that has been loaded by the runtime as the application is being executed.
Autos: This window lists all the available objects present in the current page.
Threads: Lists all the Worker threads along with their unique id, location, category, name priority and suspend status.
Modules: This window lists all the modules available as per the loaded assemblies under the available namespaces. It also tells if they are Optimized, user code, their symbol status, version, timestamp, the process under which they are running information along with the name of the assembly they are in.
Processes: Tells about the processes that are run from this application.

What is the default access modifier for the member? 

  VB.NET C#
Class variable Private Private
Class method Public Private
Structure variable Public Public
Structure method Public Private
  

What are code groups in .NET?

Code group is a logical grouping of code that follows some given conditions for membership. Code groups have some permission sets that are checked before to grant the membership of the code group.
 

Define Data Access Modifier. 

Access Modifiers or Access specifiers provide a class, a variable or a function with accessibility. It means that they govern who can access them.

What are the access modifiers available?    

Answer
There are five different access modifiers:
  • public: It specifies that it can be accessed by anyone.
  • private: Private declared variables, classes or functions can be accessed only by the member functions. No one from outside the class can access them.
  • protected: This access specifier is useful in a hierarchy wherein an access can be given only to the child classes.
  • internal: These limit an access only within an assembly. Its is similar to a friend function of C++.
  • protected internal: These limit the access within the assembly and to the child classes in the hierarchy  

What is strong-typing versus weak-typing? Which is preferred? Why?

In weak typing, it is allowed to define a block of memory as another type (casting).
Languages like C, C++ are weakly and statically typed.
Languages like Perl and PHP are weakly typed as you can add numbers to strings and they will implicitly coerce it.
Languages like Java, C# and Python are strongly typed. In these the type conversion needs to be explicitly handled.
For scripts we use weak typing.
In big programs, we use strong typing which can reduce errors at compile time.