SQL BI Instructors Online

Types of keys is SQL Server

What is Key? Keys are fields in a table which participate in below activities in RDBMS systems:

  • To create relationships between two tables.
  • To maintain uniqueness in a table.
  • To keep consistent and valid data in database.
  • Might help in fast data retrieval by facilitating indexes on column(s).

SQL Server supports various types of keys, which are listed below:

  1. Candidate Key
  2. Primary Key
  3. Unique Key
  4. Alternate Key
  5. Composite Key
  6. Super Key
  7. Foreign Key

Before discussing each type in brief, have a look on the below image used as an an example to define types of keys.

Lets discuss each type in detail:

  • Candidate Key: Candidate key is a key of a table which can be selected as a primary key of the table. A table can have multiple candidate keys, out of which one can be selected as a primary key.

Example: Employee_Id, License_Number and Passport_Number are candidate keys

  • Primary Key: Primary key is a candidate key of the table selected to identify each record uniquely in table. Primary key does not allow null value in the column and keeps unique values throughout the column. In above example, Employee_Id is a primary key of Employee table. In SQL Server, by default primary key creates a clustered index on a heap tables (a table which does not have a clustered index is known as a heap table). We can also define a nonclustered primary key on a table by defining the type of index explicitly.

A table can have only one primary key and primary key can be defined in SQL Server using below SQL statements: CRETE TABLE statement (at the time of table creation) – In this case, system defines the name of primary key ALTER TABLE statement (using a primary key constraint) – User defines the name of the primary key Example: Employee_Id is a primary key of Employee table.

  • Unique Key: Unique key is similar to primary key and does not allow duplicate values in the column. It has below differences in comparison of primary key:

It allows one null value in the column. By default, it creates a nonclustered index on heap tables. Alternate Key Alternate key is a candidate key, currently not selected as primary key of the table. Example: License_Number and Passport_Number are alternate keys.

  • Composite Key: Composite key (also known as compound key or concatenated key) is a group of two or more columns that identifies each row of a table uniquely. Individual column of composite key might not able to uniquely identify the record. It can be a primary key or candidate key also.

Example: In salary table, Employee_Id and Salary_Month_Year are combined together to identify each row uniquely in Salary table. Independently Employee_Id or Salary_Month_Year column cannot identify each row uniquely. We can create a composite primary key on Salary table using Employee_Id and Salary_Month_Year columns.

  • Super Key: Super key is a set of columns on which all columns of the table are functionally dependent. It is a set of columns that uniquely identifies each row in a table. Super key may hold some additional columns which are not strictly required to uniquely identify each row. Primary key and candidate keys are minimal super keys or you can say subset of super keys.

In above example, In Employee table, column Employee_Id is sufficient to uniquely identify any row of the table, so that any set of column from Employee table which contains Employee_Id is a super key for Employee Table. For example: {Employee_Id}, {Employee_Id, Employee_Name}, {Employee_Id, Employee_Name, Address} etc. License_Number and Passport_Number columns can also identify any row of the table uniquely. Any set of column which contains License_Number or Passport_Number or Employee_Id is a super key of the table. For example: {License_Number, Employee_Name, Address}, {License_Number, Employee_Name, Passport_Number}, {Passport_Number, Employee_Name, Address, License_Number}, {Passport_Number, Employee_Name}, {Passport_Number, Employee_Id} etc.

  • Foreign Key: In a relationship between two tables, a primary key of one table is referred as a foreign key in another table. Foreign key can have duplicate values in it and can also keep null values if column is defined to accept nulls.

Example: Employee_Id (primary key of Employee table ) is a foreign key in Salary table.

How to delete a record in a table using SQL?

The SQL DELETE Query is used to delete the existing records from a table.

You can use WHERE clause with DELETE query to delete selected rows, otherwise all the records would be deleted.

Syntax:
The basic syntax of DELETE query with WHERE clause is as follows:

DELETE FROM table_name
WHERE [condition];

Example:
Consider the CUSTOMERS table having the following records:
+—-+———-+—–+———–+———-+
| ID | NAME | AGE | ADDRESS | SALARY |
+—-+———-+—–+———–+———-+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |

Following is an example, which would DELETE a customer, whose ID is 6:

DELETE FROM CUSTOMERS
WHERE ID = 6;

If you want to DELETE all the records from CUSTOMERS table, you do not need to use WHERE clause and DELETE query would be as follows:

DELETE FROM CUSTOMERS;

SQL Server next version CTP 1.4

Microsoft is excited to announce a new preview for the next version of SQL Server (SQL Server v.Next). Community Technology Preview (CTP) 1.4 is available on both Windows and Linux. In this preview, they added the ability to schedule jobs using SQL Server Agent on Linux. We can try the preview in your choice of development and test environments now: www.sqlserveronlinux.com.

Key CTP 1.4 enhancements
The primary enhancement to SQL Server v.Next on Linux in this release is the ability to schedule jobs using SQL Server Agent. This functionality helps administrators automate maintenance jobs and other tasks, or run them in response to an event. Some SQL Server Agent functionality is not yet enabled for SQL Server on Linux. To learn more and see sample SQL Server Agent jobs, you can read detailed blog titled “SQL Server on Linux: Running scheduled jobs with SQL Server Agent” or attend an Engineering Town Hall about “SQL Server Agent and Full Text Search in SQL Server on Linux.”

The mssql-server-linux container image on Docker Hub now includes the sqlcmd and bcp command line utilities to make it easier to create and attach databases and automate other actions when working with containers. For additional detail on CTP 1.4, please visit What’s New in SQL Server v.Next, Release Notes and Linux
documentation.

In addition, SQL Server Analysis Services and SQL Server Reporting Services developer tools now support Visual Studio 2017. They are available for installation from the Visual Studio Marketplace providing the option for automatic updates going forward.

 

Get SQL Server v.Next CTP 1.4 today!
Try the preview of the next release of SQL Server today! Get started with the preview of SQL Server with our developer tutorials that show you how to install and use SQL Server v.Next on macOS, Docker, Windows, and Linux and quickly build an app in a programming language of your choice.

SQLServer, SQL DBA, MSBI Training Certification

For details, please visit www.sqlschool.com/Certifications

Microsoft Certifications Training

 

Microsoft Certifications Training For SQL Server, SQL DBA and MSBI [MCSE]

70-461 Training, 70-462 Training, 70-463 Training, 70-466 Training, 70-4657 Training

For details, please visit www.sqlschool.com/Certifications 

Choose SQL School for Real-time and Practical Trainings with Projects and Placements.

24×7 LIVE Server access and salient highlights of our Project Oriented On-Job Trainings, our courses are carefully designed with keeping in view, a starter in SQL Server technology. Prices are very much competitive and option to pay in installments for DBA and MSBI courses is an added choice of relief.

Real-time project absolutely FREE for every course you sign up!

SQL Server, SQL DBA and MSBI Trainer @ SQL School

What our customer say? Google | Facebook | Sulekha | Just Dial | Grotal | Yet 5 |ThinkVidya| View More

 

 

 

Register Today for Free Demo : SQL Server, SQL DBA, MSBI Trainings

Reach Us today for Free Demo

Email: contact@sqlschool.com

USA: +1 (510) 400 – 4845

India: +91 (0) 9666440801    /    040 64577244

SQL School: Best Trainers for Microsoft SQL Server Technologies

SQL School: Best Trainers for Microsoft SQL Server Technologies

Choose SQL School (http://www.sqlschool.com) for LIVE Online, Classroom and Video Trainings.

SQL School: Best Trainers for Microsoft SQL Server Technologies

Best Trainers for Microsoft SQL Server Technologies

 

SQL School: Best Trainers for Microsoft SQL Server Technologies 

 

About SQL School Training Institute

SQL School (Regd: SequelGate Innovative Technologies Pvt. Ltd.) is strongly committed to provide complete real-time and practical training exclusively on Microsoft SQL Server and Datawarehousing technologies. SQL School Training Institute established in February, 2008 is now one of the best training institute offering SQL Server and T-SQL (SQL Server) Training, SQL Database Administration (SQL DBA) Training and Business Intelligence (MSBI / SQL BI) Training.

 

Training Highlights:

  • Highly Interactive, Practical
  • Certifications & Resumes
  • Placements & Job Support
  • THREE Realtime Case Studies
  • One Real-time Project
  • 24×7 LIVE Server with Lab

 

 

Continue reading

SQL School is rated the BEST Training Center for SQL Server and MSBI

https://www.google.co.in/?gfe_rd=cr&ei=OnhhVZfHG6_v8wequYHAAQ&gws_rd=ssl#q=sql+school

https://www.google.co.in/?gfe_rd=cr&ei=OnhhVZfHG6_v8wequYHAAQ&gws_rd=ssl#q=sql+school

 

SQL School Training Institute (www.sqlschool) offers you complete practical real-time trainings.

Courses Offered:
1. SQL Server Developer Course (http://sqlschool.com/TSQL-Online-Training.html)
2. SQL DBA Course (http://sqlschool.com/SQLDBA-Online-Training.html)
3. MSBI Course (http://sqlschool.com/MSBI-Online-Training.html)
4. SSIS Course (http://sqlschool.com/SSIS-Online-Training.html)
5. SSAS Course (http://sqlschool.com/SSAS-Online-Training.html)
6. SSRS Course (http://sqlschool.com/SSRS-Online-Training.html)

To register for free demo:
http://sqlschool.com/contact.html

Call Us:
Mail: contact@sqlschool.com
Skype: SQL School
USA (001): (510) 400 – 4845
India (0091): 9666440801

SQL Server and SQL DBA Training + Relatime Project : Free Demo

SQL Server and SQL DBA Training + Relatime Project : Free Demo

Please register for SQL Server (T-SQL) & DBA Training Free Demo on Nov 13, 2014 6:00 AM India Time at:

https://attendee.gotowebinar.com/register/3899755899850178562

After registering, you will receive a confirmation email containing information about joining the webinar.

 

SQL Server Online Training

SQL Server Online Training

 

SQL Server and SQL DBA Training + Relatime Project : Free Demo