What are the Major Part of a SQL DB?



Parts of a Database

A SQL database is used to store and retrieve data.  The database is housed in a database server and largely controlled by a database management system.  All SQL databases, whether they MS SQL Server, MySQL, Oracle, or Progress have several components in common.  They are:

  • Tables
  • Indexes
  • Views
  • Stored Procedures
  • Triggers

It is these various pieces that are used to house, retrieve, and process data with the SQL database.

SQL Database Tables

Tables are used to store data within the database.  They are its main component and without them, the database would serve little purpose. Tables are uniquely named within a database.  Many operations, such as queries use these names.  Typically a table is named to represent the type of data stored within.

For example, a table holding employee data may be called Employees. A table consists of rows and columns.  The columns are defined to house a specific data type, such as dates, numeric, or textual data.  Each column is also given a name.  Continuing with our example, an employee’s name may defined in the table as two columns as FirstName and LastName.

Read More: Database Normalization – in Easy to Understand English >>


Indexes are used to make data retrieval faster.  Rather than having to scan an entire table for data, an index allows the database to, essentially, directly retrieve the data being asked of it.  An index consists of keys, which in most cases directly relate to columns in a table.

For example, we could create an index using FirstName and LastName to make it quicker to look up employees by their name. Once common property of an index is uniqueness.  If an index is unique, then it can only contain unique values for its defined keys.  In our employee example, this wouldn’t be practical, as a company may have more than one John Smith working at it; however, it would make sense to create a unique index on employee number.


Relationships between SQL database tables can become quite complicated as data is stored in separate tables.  Views help combat this issue by allowing the database administrator to create “canned” or pre-built queries that developers, report writer, and users can use in their own database queries.  In this way, the view hides some of the database complexity.  This makes it easier to read queries; however, danger does lurk in this as it can be easy to forget the amount of processing a view represents.

Stored Procedures

There are many situations where queries alone are insufficient to solve a problem.  In these cases, developers rely on programming languages to process logic, to loop through records, and perform conditional comparisons as required.  These programs can be stored in the SQL database as stored procedures.

The language used to create the stored procedures are vendor specific.  T/SQL is the language used by Microsoft SQL Server; whereas, PL/SQL is used by Oracle. In each case the language provides the same basic abilities, such as being able to move record by record through a query, perform if-then logic, and call special built in functions to assist with complicated calculations.


Triggers are special instructions that are executed when important events, such as inserting or updating records in a table happen.  The most common triggers are Insert, Update, and Delete triggers.  Two items define a trigger on a table: a stored procedure and an event, such as inserting a record that invokes its execution.

In our employee example, we may want to keep track every time an employee record is updated.  To do this, you could create an update trigger which calls a stored procedure to update the affected row’s modification date. Triggers are useful to ensure that data is update consistently.  You don’t have to rely on the user or program that originally modified the employee to also modify the date.

Remember!  I want to remind you all that if you have other questions you want answered, then post a comment or tweet me.  I’m here to help you.

8 responses to “What are the Major Part of a SQL DB?”
  1. […] Databases mainly consist of sets of related tables, which house data, all centered on a central topic or purpose.  For instance an Accounting database would house tables all related to storing and processing account transactions. […]

  2. Jared

    Super simple here. Tank you mang!!

  3. Krishnakumar

    This is awesome website for learning DATABASE when anyone not known anything about Database it’s very useful don’t stop try to do different languages for website….thanks…

    1. Hi – I’m glad you like the site. My hope is that I’m able to teach people to learn SQL. As you can see, the site is more than just a reiteration of SQL syntax@

      1. ed

        really appreciate how you’re covering the foundations of databases in your site. it’s helping me get a handle of how things function at a deeper level.

        1. Thanks for letting me know! That made my day. :)

  4. Way to boil down some pretty complex thoughts into concepts most people can understand. When my 95-year old grandmother asks me about my data analysis, I usually don’t even know where to start, and she doesn’t let me off the hook. So this is a good approach. Best yet, each element here can be tied back to the business easily.

    1. Thanks! I’m really hoping to make db’s simpler for everyone to use. There is such a steep learning curve!

      Thanks for the comment and compliment.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from the blog

MySQL PostgreSQL SQLite SqlServer