Pleeease...What is the cursor, index, and cluster?with an example
I studied computer sience in the university?
In my study we practice some SQL statements with Oracle, and SQL Server
Also, We studied some database concepts like
But, until now I haven't clear opinion about CLUSTERS, INDEXES, and CURSORS in the database?
Please give an overview about them with small examples to clarify
While I await some help of my own, I can tell you this:
You should look at an index as separate file. This file contains some of the values from the table to which the index is associated. The index file is sorted to meet a specific requirement.
Example: You have an Invoices table and an Invoice_Line_Items table. Invoices of course contains information specific to the Invoice itself i.e. Invoice Date, Customer Number, etc.
Invoice Line Items are the items included on the Invoice. You probably already know all that.
Let's say Invoice_Line_Items has 4 fields: The Invoice_Number (to which this set of Invoice_Line_Ites is related, Line_Number (assume that as items are added to an invoice, the new line item is assigned the next Line_Number), and Product_Number (the product being sold) and Quantity_Sold.
Now let's say you need to print or display the Invoice and it's line items. You probably want the Line Items to be printed or displayed in the same order as they were created. You would build an index on Invoice_Number + Line_Number from your Invoice_Line_Items table.
DBMS's use indexes to read thru the data in a table. The programmer would dictate which index to use (the one I defined) when needing to print or display an Invoice and it's related Line Items.
As for Cursors, my definition is a temporary table. Some call this a view or at least use the terms interchangably. It is some subset of the data from one or more tables, pulled together in a temporary table.
In the indexing example above, in order to display or print an invoice you will need some data from the Invoices table and the related data from the Invoice_Line_Items table. I would create a view (I am assuming a view and cursor are the same thing), pulling the data I need from Invoices and the data I need from Invoice_Line_Items into a cursor/view named Invoice_Data.
The following relates to Microsoft SQL Server databases:
An Index orders data for faster sorting and searching. A table may have one CLUSTERED index, and the records in the table are stored in the physical order determined by this index. A table may have one or more non-clustered indexes. These are separate objects that store the indexed values along with pointers to the original data.
A CURSOR is neither a temporary table or a view. It is a method of stepping through a dataset (such as a table or view) and operating on a single record at a time. Because it is not a set-based transaction, it is almost never an efficient method of reading or editing data.
Please note that CLUSTER can also refer to a group of database servers operating together for failover security.
If it's not practically useful, then it's practically useless.