1 Replies - 897 Views - Last Post: 21 December 2008 - 08:22 PM Rate Topic: -----

#1 dreamincodehamza   User is offline

  • D.I.C Regular
  • member icon

Reputation: -12
  • View blog
  • Posts: 349
  • Joined: 12-September 08

database questions

Post icon  Posted 21 December 2008 - 11:46 AM

I need to know that
in dynamic websites triggers , views , indexes are implemented
where in database and why.
Is This A Good Question/Topic? 0
  • +

Replies To: database questions

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5207
  • View blog
  • Posts: 13,955
  • Joined: 18-April 07

Re: database questions

Posted 21 December 2008 - 08:22 PM

Well the "where" is different from database to database. Typically on databases like SQL Server you can access them and create them through tools like query analyzer or enterprise manager (especially for 2000).

A view can be seen as a lense in which data is put together custom for the user. They can be simple showing something like a table in the database or can be complex made up of various fields from different tables smashed together to form new data.

For example, a manager may need a report on sales over the last month. A view can be constructed which links the orders table with order details and each detail line being linked with the specific product. They don't want things like product if it is in stock or not but may want the fields referring to quantity on hand and price. Then they want to know the total value of each product sold on that order which would require multiplying the quantity on hand with the price. So a database administrator can link the tables using a query, exclude or add fields and create a customized "view" for the manager. If the database was a house, a view would be the window where you could look in and see some things, but only what is brought to the window from the rest of the house.

Triggers are code procedures, queries, snippets that are "triggered" in response to a user doing something on the database. You could create a trigger which would delete order details from the orderdetails table if the order record was deleted from the orders table. Another trigger may modify a record in one table if it detects another record (in another table) was added or modified. Just like it sounds, doing something to the data in a database may trigger other code to run.

Indexes are just like an index in a book, used to quickly locate and organize data. They are often put on one or many fields and allow the database to quickly find records during a search. Instead of going through each page of a book, you can quickly go to the index, look up a topic, and jump to the appropriate page. Just like in a book an index in a database can be used to quickly jump to the appropriate records in a table and speed up finding and reading items.

Indexes are usually put on fields which are unique in nature and very easy to categorize. You wouldn't want to put an index on a field which may have several records with the same value. For this reason you find indexes on primary keys, numerical fields that auto increment, fields which are pretty wide ranging in values. If you had a table listing cities in washington state, you would probably put an index on the latitude and longitude numbers (since they would be unique for each record), but not the field for state since all items would have "Washington" as the state.

You can find more info on all these relatively easy with a quick search. So if you are still fuzzy, be sure to check it out online.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1