SQL CROSS JOIN will return all records where each row from the first table is combined with each row from the second table. Which also mean CROSS JOIN returns the Cartesian product of the sets of rows from the joined tables.
in other meaning Cross Joins produce results that consist of every combination of rows from two or more tables That means if table A has 3 rows and table B has 2 rows, a CROSS JOIN will result in 6 rows. There is no relationship established between the two tables – you literally just produce every possible combination.
it is useful if you do lots of report writing in SQL, a CROSS JOIN can be your best friend.
you can create Cross join in two ways
1. using join keyword
2. list all the tables in the from clause separated by comma without using where
Monday, November 30, 2009
Wednesday, November 25, 2009
AND & OR & NOT and its relation with SQL performance
* Using the AND operator typically results in a smaller result set, thus improving performance
* The NOT operator typically hurts performance because the query optimizer cannot use indexes for the where clause when a NOT operator is specified
* For Indexes to be utilized when an OR operator is specified, all columns referenced by the OR condition must be included in an index or none of the indexes are used
* The NOT operator typically hurts performance because the query optimizer cannot use indexes for the where clause when a NOT operator is specified
* For Indexes to be utilized when an OR operator is specified, all columns referenced by the OR condition must be included in an index or none of the indexes are used
Saturday, November 21, 2009
Have Look at Data Type of SQL Server 2008
Character Types
Exact Numbers
Approximate Numeric Types
- The text and ntext types are both deprecated in SQL server 2008 so avoid using them, they have been replaced by varchar(max) and nvarchar(max).
- The difference between char and varchar is that char is fixed length and varchar is variable length .
- The advantage of using char over varchar is that updates made to a char column never require moving the row because the data that is entered always fits in the allocated space
- What about nchar and nvarchar? both of these data types store characters using the Unicode Universal Code Page (UCS-2). this means that if you use nchar or nvarchar, you can store any type of character regardless of the collation you choose because two bytes are always used to store each character. contrast with varchar and char, which store characters using one or two bytes depending on the collation.
- Note that: if you want to use different collation than the one specified on a column when making te comparsion
............ where Name='Mohamed' COLLATE Finnish_Swedish_CI_AS
- To get all the collations of the SQL Server 2008 by using table valued function fn_helpcollations
Select *
From fn_helpcollations()
Exact Numbers
- Difference between Decimal Types & numeric:
- when using the decimal data type, you can specify the precision and scale of values stored using the data type. the precision defines the total number of digits that the data type holds, supporting a maximum precision of 38 and the scale defines how many of the digits defined by the precision are used as decimals.
Approximate Numeric Types
- the float data type accepts a parameter. the parameter supplied to the float data type defines the number of bits that are used to store the mantissa of the floating point number
Thursday, November 19, 2009
Pointer in JAVA
The main difference between C++ and JAVA or C# is that C++ has pointers and Java or C# doesn't
in C++
Student bill;
bill = new Student();
bill.GPA = 4.0;
in Java
Student* bill;
bill = new Student;
bill->GPA = 4.0;
Note That
Yes, they are called "reference types". The references point to objects.
You mean that you cannot have objects as values, then yes.
simple data type called Yes, they are called primitive types.
Basically. There is no way to "take the address" of a variable. But you can copy the value of the variable into a field of a wrapper object, which then can be pointed to by a reference.
in C++
Student bill;
bill = new Student();
bill.GPA = 4.0;
in Java
Student* bill;
bill = new Student;
bill->GPA = 4.0;
Note That
Yes, they are called "reference types". The references point to objects.
You mean that you cannot have objects as values, then yes.
simple data type called Yes, they are called primitive types.
Basically. There is no way to "take the address" of a variable. But you can copy the value of the variable into a field of a wrapper object, which then can be pointed to by a reference.
Difference between Component && Service From Martin Fowler Thinking
Martin Flower Says:
I use component to mean a glob of software that's intended to be used, without change, by application that is out of the control of the writers of the component. By 'without change' I mean that the using application doesn't change the source code of the components, although they may alter the component's behavior by extending it in ways allowed by the component writers.
A service is similar to a component in that it's used by foreign applications. The main difference is that I expect a component to be used locally (think jar file, assembly, dll, or a source import). A service will be used remotely through some remote interface, either synchronous or asynchronous (eg web service, messaging system, RPC, or socket.)
I use component to mean a glob of software that's intended to be used, without change, by application that is out of the control of the writers of the component. By 'without change' I mean that the using application doesn't change the source code of the components, although they may alter the component's behavior by extending it in ways allowed by the component writers.
A service is similar to a component in that it's used by foreign applications. The main difference is that I expect a component to be used locally (think jar file, assembly, dll, or a source import). A service will be used remotely through some remote interface, either synchronous or asynchronous (eg web service, messaging system, RPC, or socket.)
Sunday, November 8, 2009
PONO Plain old .Net object
i read this paragraph in other blog through searching the internet to discover the meaning of the PONO and i want to share this with you:
I want to enforce that the domain is the core, the centerpiece, the kernel as you may of my application. I don’t want it to have any dependencies to other assemblies in my application, especially not the infrastructure assembly. This means that my domain assembly can only have a reference to the .NET framework assemblies and nothing else.
if domain objects are only made of primitive types, we could call PONO : Plain Old .NET Object in reference to Java POJO orPOCO, Plain Old CLR Object. Such convention garantees that domain object are re-usable across layers and potentially increase performance since all these primitive types are CLR-optimized
so in other meaning we can Just say it is a normal class, no attributes describing infrastructure concerns or other responsibilities that your domain objects shouldn't have. POJO's (for java) are just classes which dont force inheritance or any attribute markup to make them "work" in whatever framework you are using.
References
http://codebetter.com/blogs/patricksmacchia/archive/2008/06/30/simple-core-domain-types-and-plain-old-net-objects.aspx
I want to enforce that the domain is the core, the centerpiece, the kernel as you may of my application. I don’t want it to have any dependencies to other assemblies in my application, especially not the infrastructure assembly. This means that my domain assembly can only have a reference to the .NET framework assemblies and nothing else.
if domain objects are only made of primitive types, we could call PONO : Plain Old .NET Object in reference to Java POJO orPOCO, Plain Old CLR Object. Such convention garantees that domain object are re-usable across layers and potentially increase performance since all these primitive types are CLR-optimized
so in other meaning we can Just say it is a normal class, no attributes describing infrastructure concerns or other responsibilities that your domain objects shouldn't have. POJO's (for java) are just classes which dont force inheritance or any attribute markup to make them "work" in whatever framework you are using.
POCO's are the same, except in .NET.
for example, .Net 3.5 sp1 ORM example: the Entity framework requires that classes inherit from a certain framework class. LINQ to SQL does not have this requirement. Therefore LINQ to SQL works with POCOs and the Entity framework does not
PONO (plain old .net object) is equivalent to POCO (plain old CLR object)
References
http://codebetter.com/blogs/patricksmacchia/archive/2008/06/30/simple-core-domain-types-and-plain-old-net-objects.aspx
Monday, November 2, 2009
Separartion of Concerns .... thinking about Software Architecture
Concern is any piece of interest or focus in a program, in other meaning it is features or behaviors of the program.
Cross cutting concerns this concern of program which affects other concerns, these concerns often can’t be cleanly decomposed from the rest of the system in both the design and implementation. For example Security, Logging of the system, in other meaning our system won’t work alone with security and logging but with the core business logic concern. So we use cross cutting concern to integrate with core concern to get the overall functionality of the system. At the end we can say that cross cutting concerns likes the secondary concerns where the main business goals will be the primary concerns.
Separation of Concerns is the process of separating a computer program into distinct features (Concerns) that overlap in functionality as little as possible, layered designs in information systems are also often based on separation of concerns (e.g. presentation layer, business logic layer, data access layer, database layer). The goal is to design systems so that functions can be optimized independently of other functions so that failure of one function does not cause other functions to fail, and in general to make it easier to understand, design and manage complex interdependent systems.
All programming languages apply separation of concern concepts in its architecture like:
· Object-oriented programming à objects
· MVC àseparate content from presentation
· Service oriented design à separate in services
· Procedural programming à procedures
· Aspect oriented programming à aspects and objects
Sunday, November 1, 2009
Const ,Readonly, Static .....Have a Loo0ook
const Keyword
- A constant member is defined at compile time and cannot be changed at runtime.
- Constants are declared as a field, using the
constkeyword and must be initialized as they are declared. - Since classes or structures are initialized at run time with the
newkeyword, and not at compile time, you can't set a constant to a class or structure. - for example public const double PI=3.14
- so we the value of PI will be constant through all the application and can't change it and if we try to change it, will give us compilation error
readonly Keyword
- A read only member is like a constant in that it represents an unchanging value
- The difference is that a
readonlymember can be initialized at runtime, in a constructor as well being able to be initialized as they are declared. - Because a
readonlyfield can be initialized either at the declaration or in a constructor readonlyfields can have different values depending on the constructor used- A
readonlymember can hold a complex object by using thenewkeyword at initialization. readonlymembers cannot hold enumerations.readonlymembers are not implicitlystatic, and therefore thestatickeyword can be applied to areadonlyfield explicitly if required.
static Keyword
- Use of the
staticmodifier to declare astaticmember, means that the member is no longer tied to a specific object. - This means that the member can be accessed without creating an instance of the class
staticmethods and properties can only accessstaticfields andstaticevents- The
staticmodifier can be used with classes, fields, methods, properties, operators, events and constructors, but cannot be used with indexers, destructors, or types other than classes. - To access a
staticclass member, use the name of the class instead of a variable name to specify the location of the member.
Subscribe to:
Comments (Atom)
