Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

How to prevent user to not copy SQL server data files

Prevent database file from copying

I am working in a product based company and will provide SQL Server express 2014 edition with our software.
I want your expert comment on database security. 

Problem

As we are installing a database on client PC then they might be able to clone our system by attaching MDF files to another server. 

(In my view, through database objects name and data, other companies can easily identify our workflow and can develop software easily)

So I want some type of encryption or file system solution to prevent user to take database files. And yes as we are using express edition, we can't use available SQL server options.

Difference between primary key and foreign key

Difference between foreign key and primary key:

In this post I will share key differences between foreign key and primary key.

Primary Key:

The PRIMARY KEY uniquely identifies each record in a database table; main goal is to prevent duplicate values for columns and provides unique identifier to each column.

Foreign key:

Foreign key is a column or field in current table and primary key of another table, the foreign key points to another table using primary key of that table.

Differences:

Following table shows all possible differences between MS-SQL Server table primary key and foreign key.

Difference

Primary Key

Foreign Key

Limit

We can have only one Primary key in a table

We can have more than one foreign key in a table.

Null values

Primary Key can't accept null values.  

Foreign key can accept multiple null values.

Index

By default, Primary key is clustered index.

You can manually create an index (non-clustered) on foreign key.

 

Auto Increment

Primary key supports Auto Increment value.

Unique Constraint doesn't support Auto Increment value. 

Definition

The PRIMARY KEY uniquely identifies each record in a database table

Foreign key is a field in the table that is primary key in another table.

 

  धन्यवाद मित्रानोआपला प्रत्येक दिवस आनंदी आणि सुखी जावो  

SQL Views VS Temp Tables

SQL views and SQL temp tables:

Temp tables and views are totally different from each other.

View SQL query each time retrieve data from underlying base table, a temp table is a completely separate database object. It gets populated with rows when you insert them into it.

SQL Views:

View is a virtual table based on the result-set of an SQL statement and that is Stored in the database with some name.

SQL temp table:

There is important concept called temporary tables. With temporary table you can store and process intermediate results by using the same selection, update, and join capabilities that you can use with typical SQL tables.

View use:

1. Reuse some SQL query logic or reducing redundancy in writing queries.
2. Maximize performance for complex calculations and joins; provide easy results and hide complex logic.
3. Providing easy access to query logic to team members and non-developers.
4. You want to add/remove fields without modifying your underlying schema (Table schema).

Temporary table use:

1. Use a temp table if you will not reuse the structure many times or SQL query logic many times.
2. If there is logic which require manipulation of data that cannot be done within a single query, then in such cases, the output of one query / intermediate results can be stored in a temporary table which then participates in further manipulation via joins etc to achieve the final result.

Example:

Common use of temporary tables summarizes company profit Daily, Weekly, Monthly, Yearly basic. Here temp tables we can use in stored procedure to manipulate data from multiple table in single SQL query.
Another example is Custom paging for web application grid, in which we can return data in set of groups using single query and temp tables.

One common scenario in using temporary tables is to store the results of a SELECT INTO statement