What is the difference between Delete and Truncate

To order essay on an author of the essay not only that but safely. Our exchange provides a number of obligations, which guarantee customers that they will receive a high quality and decent work:

each essay is checked by the system Antiplagiat, which ensure that the text was unique;

you made your payment remains “frozen” for the author until the time the student will receive an essay on the order in hand;

real comments and feedback about each expert help to navigate, who to approach and what results to expect.

If you need to order essay on any subject, be sure to contact author of essay on here will execute any order with pleasure and in the shortest time will help you to come to the school with the custom essay uk and best hand.

Other types of work

To the exchange author of essay each day addresses a lot of clients that need professional help. Here Β who can do the work of proofreading efficiently and competently. author of essay has such features as:

It employs a lot of specialists who work with different languages. The staff is constantly to big this allows us to assist a lot more often;

The order is carried out only by experienced professionals who have diploma in this field or are the academic staff of the Universities. They thoroughly know their work and can carry out proofreading of articles;

The cost of proofreading text

Exchange author of essay can perform all sorts of work. Proofreading articles, research papers and other assignments is in accordance with all requirements and regulations. As for the cost of proofreading the texts, it may depend on:

Scope of work;

The complexity of the subject;

Deadlines.

For urgent execution, the contractor takes a percentage of the work, as it delays other work and perform an urgent task.

Posted in SQL Server | Comments Off on What is the difference between Delete and Truncate

What are Nested Transactions in SQL Server?

As the name suggests, nested transaction is one that is nested within a transaction. Let’s illustrate this with an example.

Let’s create a table:

CREATE TABLE PERSON
(
	ID INT IDENTITY(1,1),
	FirstName VARCHAR(25),
	LastName VARCHAR(25),
	Gender CHAR(1)
)
SELECT * FROM PERSON

As you can see, we have a table Person with no records.


Let’s initialize a transaction and view its count

BEGIN TRANSACTION  -- 1st Transaction
SELECT @@TRANCOUNT AS TrxCount

Now, insert a record into the table

INSERT INTO PERSON VALUES ('Bill', 'Meyer', 'M')
SELECT * FROM PERSON

Let’s initialize a second transaction and view its count:

BEGIN TRANSACTION -- 2nd Transaction
SELECT @@TRANCOUNT AS TrxCount

Let’s insert another record and then view its contents. Mind you, we are currently in a nested transaction.

INSERT INTO PERSON VALUES ('Lisa', 'Ray', 'F')
SELECT * FROM PERSON

Now, let’s rollback the transaction and do a count immediately afterwards.

--Rollback Transaction
ROLLBACK
SELECT * FROM PERSON
SELECT @@TRANCOUNT AS TrxCount


The rollback rollsback to the outermost transaction that was defined. Another thing to keep in mind is that you don’t need a COMMIT TRANSACTION in order to ROLLBACK.

Posted in SQL Server | Comments Off on What are Nested Transactions in SQL Server?

How to partition the result set in SQL Server

To query the first row or the last row in a table is easy-piecey.Β  You simply select the Top 1 row and order the query by ascending or descending. But, how about selecting the second, third or tenth row from a table that meets a certain criteria. That’s when the query gets little tricky.

I’ll show you an easy approach from start to finish. Below is a snapshot of an Employee table with a list of employees and their salaries. The Employee table as you can see is ordered by ID with a list of random salaries.

Employee Table in Descending Order:

Max Salary:

To get a maximum salary from the employee table, the MAX() function is used to get the value. Easy eh!

How about if you want to get the second highest salary? How would you shape your query? One way is to write a sub-query like so:

SELECT MAX(Salary) AS 'Max Salary'
FROM
	Employee
WHERE
	Salary < (SELECT MAX(Salary) FROM Employee)


OR

You can also do something like this, although you'll have to do a mental math to write the following query in order to get the second highest salary:

SELECT
	TOP 1 Salary 
FROM
	(SELECT DISTINCT TOP 2 Salary
	FROM
		Employee
	ORDER BY 
		Salary DESC)
	RESULT
ORDER BY
	Salary

Using DENSE_RANK() function:

WITH RESULT AS
(
SELECT Salary, DENSE_RANK() OVER (ORDER BY Salary DESC) AS RANK
FROM
	Employee
)
Select TOP 1 Salary from RESULT
WHERE RANK = 3

Summary:

The thing to remember is that numbers returned by DENSE_RANK function do not have gaps and invariably use consecutive ranks.

Happy coding πŸ™‚

Resources

Microsoft

Posted in SQL Server | Comments Off on How to partition the result set in SQL Server

What is IDENTITY value and how does it work?

An IDENTITY is a system function that returns the last-inserted identity value.

Let’s try it out in SQL Server Management Studio. Let’s create a table called Person with it’s IDENTITY starting position set to 1 with an increment value of 1 as well.

CREATE TABLE PERSON
(
	ID INT IDENTITY(1,1) PRIMARY KEY,
	FirstName VARCHAR(25),
	LastName VARCHAR(25),
	Gender CHAR(1)
)

Let’s insert three records and view them

INSERT INTO PERSON VALUES ('Bill', 'Meyer', 'M')
INSERT INTO PERSON VALUES ('Lisa', 'Ray', 'F')
INSERT INTO PERSON VALUES ('Scott', 'Johnson', 'M')
SELECT * FROM PERSON

As you can see, the first record has a starting ID of 1 and is incremented by 1.

Now let’s try and create another table and modify its IDENTITY settings a little bit:

CREATE TABLE PEOPLE
(
	ID INT IDENTITY(1000,10) PRIMARY KEY,
	FirstName VARCHAR(25),
	LastName VARCHAR(25),
	Gender CHAR(1)
)

Notice the IDENTITY now starts a 1000 with an increment value of 10.

Let’s insert three records into the PEOPLE table.

INSERT INTO PEOPLE VALUES ('Bill', 'Meyer', 'M')
INSERT INTO PEOPLE VALUES ('Lisa', 'Ray', 'F')
INSERT INTO PEOPLE VALUES ('Scott', 'Johnson', 'M')
SELECT * FROM PEOPLE

To view the last ID that was inserted into the PEOPLE table, you can do so by issuing the following query:

SELECT @@IDENTITY AS 'Identity'

Posted in ORM | Comments Off on What is IDENTITY value and how does it work?

What is Mongo DB and why should you use it!

The word Mongo is derived from the world humongous. So in essence, it implies that its sole purpose is to store mammoth amounts of data or what is otherwise coined as ‘big data’.

MongoDB is a document oriented database unlike its traditional relational counterparts such as SQL Server, DB2, Oracle, PostgreSQL etc.Β  MongoDB uses a JSON like syntax which is made up of name value pairs.

The fact that MongoDB is a document database, one of the rules that govern MongoDB is that every document must be unique. Hence it should have an ID. It’s also important to remember that the size of this document is typically 16MB.

MongoDB is elastic and therefore scales horizontally unlike RDBMS that scale vertically.

One of the key concepts of MongoDB is that there should always be a copy of the primary database (although not required), it is recommended that there be at least two copies of a database. In the event of a failure of primary database, the database can be restored from one of secondary servers.

The world we live in today where businesses are constantly evolving, billions of people and ‘things’ are always communicating, changing the way organizations and customers interact with each other and the environment around them. Data comes from different geographical locations and across multiple channels. Managing this explosion of high-velocity dynamic data while maintaining customer privacy is a challenge with legacy systems to say the least. That said, data is therefore of paramount importance for any organization large or small.

The solution to support rapidly growing applications is to scale horizontally by adding servers instead of concentrating more capacity in a single server. NoSQL databases, on the other hand, usually support auto-sharding, meaning that they natively and automatically spread data across an arbitrary number of servers, without requiring the application to even be aware of the composition of the server pool. Data and query load are automatically balanced across servers, and when a server goes down, it can be quickly and transparently replaced with no application disruption. This is especially an ideal situation for web applications.

While it is true that NoSQL databases lack transaction support and semantics database element that offers guarantees about data consistency and persistence. This is a solid tradeoff based on MongoDB’s goal of being simple, fast, and scalable. Once you leave those heavyweight features at the door, it becomes much easier to scale horizontally.

Some of the big 20 companies such as Google, Facebook, LinkedIn use NoSQL databases and it fits very well with their business model. That said, MongoDB has truly become a global company with over 50,000 members, 100 User Groups all around the world. As it stands right now, MongoDB has 29 offices in 14 different countries with over 3000 customers.

What’s in MongoDB

  • Key-values stores (JSON like syntax i.e. key/value pairs)
  • Column Family Stores (hierarchical schemas)
  • Document Databases
  • Multi-nested data
  • High velocity data coming at a very high rate of speed
  • Graph Databases
  • Unstructured data and by not enforcing transactional consistency
  • Document oriented databases are schema-agnostic. This allows for agility and highly iterative development
  • Durability when used in tandem with at least three servers (minimum)
  • Profiling Queries

Types of NoSQL Databases

Is MongoDB the Right Choice?

While it’s all fine and dandy to jump to this new shiny NoSQL database, but you ought to step back and ask yourself the following questions:

  • What are some of characteristics of my data?
  • What are the business needs of my data?
  • Am I required to query across multiple tables and possibly across multiple databases?
  • Do I need my data to be transactional?

Benefits

There’s no question, when compared to relational databases, NoSQL databases are more scalable and provide superior performance. Following are some of its benefits:

  • Speed and large volumes of rapidly changing structure, semi-structure and unstructured data
  • Open source, hence mostly Free
  • Object-oriented programming that is easy to use and flexible
  • Simplicity (with virtually no complex rules i.e. tables, relationships and less Object-Relational impedance mismatch
  • Geographically distributed scale-out architecture instead of expensive, monolithic architecture

Format

MongoDB uses an open data forma called BSON which is similar to the JSON format. The BSON data format was developed by the MongoDB team. This format is special in that it facilitates searching of documents rapidly including the ability to add types for handling binary data. MongoDB stores data in BSON documents which is self-contained.

Scaling

Relational databases are designed to scale vertically, in that a single server has to host the entire database to ensure acceptable performance for cross-table joins and transactions. This can become an expensive proposition while placing limits on scale. The solution to support rapidly growing applications is to scale horizontally, by adding servers or cloud instances instead of concentrating more capacity in a single server.

References

www.MongoDB.com

http://Dataconomy.com/sql-vs-nosql-need-know

Posted in NoSQL | Comments Off on What is Mongo DB and why should you use it!

Are stored procedures pre-compiled?

Contrary to the popular belief that a stored procedure is pre-compiled when created is not true.
In fact, stored procedure is compiled on the first run or the time when the stored procedure is first executed.

more to come…

Posted in ORM | Comments Off on Are stored procedures pre-compiled?

What is Managed and Unmanaged Code?

Managed Code:

The .NET framework provides several core run-time services to the programs that run within it. For example; Exception Handling and Security. In order for these services to work, the code must provide a minimum level of information to the runtime. Code that executes under the control of the runtime is called Managed Code.

Similarly, the data that is allocated and freed by the .NET runtime’s garbage collector is called Managed Data.

Benefits of CLR:

  1. Objects are self-describing
  2. Provides Code-Access-Security
  3. Assembly based deployment to avoid DDL hell
  4. Code development made easy
  5. Side-by-side versioning of reusable components
  6. Automatic Object Lifetime Management
  7. Seamless integration between CLR compliant languages

Unmanaged Code:

Code that runs outside the runtime is called unmanaged code. COM components, ActiveX interfaces, and Win32 API functions are examples of Unmanaged Code. If you have coded in VB 6 or VC++, chances are you are already familiar with these unmanaged applications. In essence, unmanaged code is one that compiles directly to machine code. Unmanaged code lacks some of the key features such as Code-Access-Security or Memory management which were not available in the runtime. However, it was only accessible through the operating system through API calls provided in the Windows SDK.

Interoperability:

The common language runtime exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object.

The image below shows how COM objects can be accessed through the runtime callable wrapper.

Consuming COM from .NET:

Following are the steps to expose COM components to the .NET Framework:

  • Import a type library as an assembly
  • Create COM types in managed code
  • Compile an interop object
  • Deploy an interop application

Please note, starting with VS 2010, you can embed type information from an interop assembly directly into your executable by instructing the compiler.

Resources:

MSDN

Microsoft Docs

 

 

Posted in .NET | Leave a comment

Repository Pattern

The Repository Pattern is used to separate the logic that retrieves the data and maps it to the entity model from the business logic that acts on the model.

The repository acts as a mediator between the data source layer and the business layers of the application.

It queries the data source for the data, maps the data from the data source to a business entity, and persists changes in the business entity to the data source. A repository separates the business logic from the interactions with the underlying data source or Web service. The separation between the data and business tiers has three benefits:

  • It centralizes the data logic or Web service access logic.
  • It provides a substitution point for the unit tests.
  • It provides a flexible architecture that can be adapted as the overall design of the application evolves.

More to come…please stay tuned.

Posted in .NET | Comments Off on Repository Pattern

How to handle Many-to-Many Relationship in EF Core

There are a few steps that are instrumental in handling a Many-to-Many relationship in EF Core. It must be noted that EF Core 1.1 does not support Many-to-Many relationship right off the bat. However, with a junction table in hand, you can achieve this in just a few easy steps. Here’s how:

Let’s write a couple of POCO classes first. Below are the two main classes, namely Department and Employee respectively. Let’s just assume the relationship between the two is Many-to-Many.

    class Department
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Location { get; set; }

        public List DepartmentEmployees { get; set; }
    }
    class Employee
    {
        public int ID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }

        public List DepartmentEmployees  { get; set; }
    }

As indicated above; in order for it work, we need a join table such that it can contain foreign keys of Department and Employee Classes like so:

class DepartmentEmployee
    {
        public int DepartmentID { get; set; }
        public int EmployeeID { get; set; }

        //Navigation Properties
        public Department Department { get; set; }
        public Employee Employee { get; set; }
    }

Now, add a class which is to be derived from DbContext. For this, ensure that you have the necessary packages installed which are the following:

  1. Microsoft.EntityFrameworkCore.SqlServer
  2. Microsoft.EntityFrameworkCore.SqlServer.Design
  3. Microsoft.EntityFrameworkCore.Tools

Please note, I have installedΒ  SqlServer.Design package only because, I am using SQL Server. If I were using DB2, I would need to install the DB2.Design package and so on.

class DepartmentContext : DbContext
    {
        public DbSet Department { get; set; }
        public DbSet Employee { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(@"server=obi-oberoi; database=demo.ManyToMany; trusted_connection=true;");
        }
    }

Now, let’s try and add our first migration using the Package Manager Console window and see what we get:
PM>add-migration initial

InitialMigrationNotice, the message that says “The entity type “DepartmentEmployee” requires a primary key to be defined”. This is because EF Core could not discover a primary key in the DeparmentEmployee model even though the composite key i.e. DepartmentID and EmployeeID are defined in the class.

One thing to keep in mind though is that in order for a Join table to work, you need composite primary key(s). However, the creation of a composite key cannot be achieved simply through Data Annotations as it only provides a scaled down version of Fluent API. For that you need a Fluent API.

In order to resolve this, let’s override the OnModelCreating() method in our context and configure the ModelBuilder API that’ll define the shape of our entity, the relationship and how it maps to the database.

Given that it’s a composite key, it’s made up of the DepartmentID and EmployeeID.

    class DepartmentContext : DbContext
    {
        public DbSet Department { get; set; }
        public DbSet Employee { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(@"server=obi-oberoi; database=demo.ManyToMany; trusted_connection=true;");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity()
                .HasKey(d => new { d.DepartmentID, d.EmployeeID });
        }
    }

Now, let’s try adding a migration.CompositeKeyand it worked!!!

Posted in ORM | Comments Off on How to handle Many-to-Many Relationship in EF Core

What are Design Patterns in modern software development

BitStarz is such casinos with Western flair. They first conquered the Western market, and then decided to return to roots. Casino has positioned itself as one of the first bitcoins (still in 2014) and now regularly enters the news with information about the big wins on chops, millions of rubles. The casino uses the platform of the Belarusian SoftSwiss integrator with more than 20 popular software. I casino played with varying success, in the end, a bit lost but satisfied with the game. Reviews from other players are also mostly positive. Basically, not much worse and some online casinos powered by SoftSwiss, you can also recommend BetChan and Play Amo .

Goldfishka is “mishandled Cossack” from the Western world to us in a Runet. It is the only such casino, which was owned by a large Western group of Fortune Lounge (there is a few casinos and the poker room) and licensed in one of the most respected areas of the canadian province of Kahnawake. The casino uses software is a recognized leader casinosno softostroeniya Microgaming. A downloadable version of this casino (in the Goldfishka, however, appeared only in 2010, and since opening in 2002 was the flash version) now contains more than 700 games and every year adds a few dozen new. If to briefly summarize, we have quality software, the coolest jackpots (several million dollars), various Russian ways of I / o, the ability to play in dollars, rubles or euros (respectively, bets can be between 1 and 100 rubles, or $1-$100 on roulette and card games or a penny/dime in the slot in any purse), a good support.

First Deposit gives 100% bonus with no limits on the amount, plus there is a good rewards program and other promotions. Last time, heard the cries of the type “Goldfishka – Scam”, but somehow, without specific figures. I dont believe it, the fact that the casino software the Microgaming can “tweak” the game so with honesty, everything should be fine like here http://rouletteplanet24.com/ – french roulette I personally have played there many times even on Vlasova software and in most cases managed to finish the game in the black. So I have no complaints, I recommend!

Posted in ORM | Comments Off on What are Design Patterns in modern software development