this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Friday, June 17, 2011

Which datatype is good for my database field?

Every time at the designing of new database table we stuck for the choosing right datatype for the particular field.

It has been said that if there is right database design have been done, it’s easy to accomplish changes in the application. If you require to change database field type or require to add new field in the table, it costs a lot at later stage.

So with this confusion of choosing right database, I have some check list what to use for the string type field.

Consider following points for your string data field.

àWhat will be max size of field, how many characters could be there?

àIs there any fix length I will have?

àDoes field require using Unicode character?

There are basic for three types of datatype are supported.

Char : this datatype can be used when we know our field’s data. We have prior idea of value. It will be good to use this type.

Varchar: when we are not firm about the value come in the field, this can be the choice.

Now one interesting datatype

Nvarchar: this is same as varchar expect it stores value as Unicode character.

Unicode character are especially useful when we would like to support Multilanguage in application else there is not much reason to use it without any purpose.

Nvarachar datatype occupies double space than the varchar, it should be considered when there will be large amount of data will be feed in the system.

You can check it with following sample

After running query you will notice that varchar datatype takes less space compared to others.

declare @na char(30)

SET @na = 'shailesh'

declare @nam nvarchar(30)

SET @nam = 'shailesh'

declare @name varchar(30)

SET @name = 'shailesh'

select datalength(@na)

select datalength(@nam)

select datalength(@name)

Monday, June 13, 2011

LightSwitch the new approach for RAD

Light Switch is the new technology or you can say new development IDE provided by the Microsoft. It’s based on the .net framework seats on the silverlight, through which you can build out desktop as well as web application.

Currently it’s available in the beta version and you can download it from here.

All the required software and hardware configuration are listed out on the page.

Languages Supported: Currently light switch support vb.net and c#.

Core parts of Light Switch

Data: this is one of the very basic parameter we use for any light switch application. During the development we should use any of the data store to be used in the application.

Screen: As it names implied it deals with the User interface of the application. In light switch user interface can be created from the underlying data structure. We can also customize the screen at the runtime. This would be best features so far we get facility at the runtime.

Queries: in the data store we can use customized query too. It’s not necessary to use plain data for the application, we can attach query that is created from more than on data store.

Code: As we have told that we can built out application without writing single line of code, but sometime it requires to change basic functionality provided by framework. We can do it so. It includes adding customize list from the code, different validation as per the business needs.

User Permission: in application we can place role based security and only authorized user can have access to system. There are so many types of user permission we could use in it.

Office Integration: many of the office features are integrated and we can directly use it. We don’t require writing custom code for it.

Deployment: Light switch application can be deployed on desktop as well as on the remote server as per the need. Light switch screen is built on the silverlight so there would be no extra item we require apart from silverlight when we use it on the web.

Apart from above mentioned parts there are so many features are available like we can place different validation on the input fields without writing any code, can customize look of application, can export data to the excel sheet, can search data in the grid, different look for the editing of record, tab panel layout for the data objects and screens.

Where it can be useful?

Light switch could be the one the best choice when we require to develop in very short period of time and for the small scale industry. It also supports various data sources behind the scene. You can use any of the data source including SQL Azure, SQL server etc.

We can say now with use of light switch developer can totally focus on the business logic and they don’t need to spend time in the insert/update and other basic coding. Even they don’t need to design screen layout.

After all business needs to have solid business logic and security.

Some useful resources

http://www.lightswitchtutorial.com/

http://msdn.microsoft.com/en-us/lightswitch/ff938857