Difference between Clustered and Non-clustered is data is physically ordered in Clustered Index whereas in Non-clusteredindex just a pointer to the data is maintained and the data is not physically sorted.
Let us try to understand the same by means of example
I have a table employee with EmployeeID and Name and I insert say these values in table one by one.
1 Bill
2 Derik
3 Andrew
4 Mark
5 John
When there is no index in the table we get the results when we select rows from the table will be
1 Bill
2 Derik
3 Andrew
4 Mark
5 John
When there is non-clustered index then also we receive the same output as above.
If we define a clustered index on Name column then we get the output as
3 Andrew
1 Bill
2 Derik
5 John
4 Mark
Its because we defined a clustered index on the Name column and hence data was sorted according to that and stored in physical disk in the same way.The advantage of this is it works best for range queries as it needs to scan the disk in sequential manner.
So ideal keys for clustered index would be columns on which range queries is used
This blog is for SQL Developers who would like to tranform themselves to DBA
Search This Blog
Friday, October 12, 2007
What is RDBMS?
RDBMS is Relational Database Management System.Examples are SQL,Oracle,DB2
We saw that excel sheet can be called as a database as it also stores the data.Morover we can store say Customer Detailsin one sheet, Items in another and say Items purchased by Customers in another sheet so what all adavantage I would get on storing it in DB rather than in excel sheet.These are many points let me list down the key points:
1) Lets suppose I want to ensure details are first entered in Customer Details before entering Items purchased by customer how do do that in excel ?
2) A customer detail should be overwrittern or deleted if he has purchased some items
3) I want to ensure that phone numbers are entered for all customers
4) I want to find all customer phone numbers who purchased say Item named "Item1", is it very simple to acheive the same in excel sheet
So basically we see like it is not possible or rather difficult to maintain a relationship or relative data in text file,excel file,word file.
That is what RDBMS provides or called as RDBMS
We saw that excel sheet can be called as a database as it also stores the data.Morover we can store say Customer Detailsin one sheet, Items in another and say Items purchased by Customers in another sheet so what all adavantage I would get on storing it in DB rather than in excel sheet.These are many points let me list down the key points:
1) Lets suppose I want to ensure details are first entered in Customer Details before entering Items purchased by customer how do do that in excel ?
2) A customer detail should be overwrittern or deleted if he has purchased some items
3) I want to ensure that phone numbers are entered for all customers
4) I want to find all customer phone numbers who purchased say Item named "Item1", is it very simple to acheive the same in excel sheet
So basically we see like it is not possible or rather difficult to maintain a relationship or relative data in text file,excel file,word file.
That is what RDBMS provides or called as RDBMS
What is Database ?
Many sites provide you information as collection of data is database.
Let me explain the same in detail with an example to be more clear.
Name is data , the place he lives is another data,his phone number is another data ,etc.So now if I combine all thisat one then it again called as set of data.Similarly say Item Description is another data,Item quantity is another data,etc.So this would be again 1 more set of data.
So these sets of data i.e. these sets or collection of data is called as database.
Now lets come to what all forms we can store this data. We can store this data in a text file, excel file,word file,etc.So what would be the difference between storing the same in above files and storing it in RDBMS like SQL,Oracle,DB2,for which look for the article what is RDBMS
Let me explain the same in detail with an example to be more clear.
Name is data , the place he lives is another data,his phone number is another data ,etc.So now if I combine all thisat one then it again called as set of data.Similarly say Item Description is another data,Item quantity is another data,etc.So this would be again 1 more set of data.
So these sets of data i.e. these sets or collection of data is called as database.
Now lets come to what all forms we can store this data. We can store this data in a text file, excel file,word file,etc.So what would be the difference between storing the same in above files and storing it in RDBMS like SQL,Oracle,DB2,for which look for the article what is RDBMS
Subscribe to:
Comments (Atom)