Definition of a Database Object
Database objects are the components that save and query information. A database contains several objects that are used to provide storage and display large, relational data. The main objects of a database are tables, stored procedures, views, users and functions. These objects are provided by Microsoft SQL Server and programmed using transaction SQL (T-SQL).
-
Tables
-
Tables are the object that most people know. However, building a proper table that provides data integrity and performance is key to a good database design. Tables are structured in rows and columns. A specific cross-point of a row and column is called a "field." This holds the data that is used in applications and reports. Relational databases store records across several tables with linked data. A poor table design can lead to slow performance and orphaned records, causing errors.
Stored Procedures
-
Stored procedures contain the queries for result sets. They are faster than inline SQL code in a web page. Stored procedures are precompiled, giving the database faster performance when called from an application. These objects can contain long, complex queries with multiple result options, or they can be simple select statements that return one record.
-
Views
-
Views and table objects are used similarly. A view is a query that is used as a table in that the programmer can link to it from another table. It's a precompiled list of record sets that is returned in a table format. Views are used when a certain query is used often. For instance, selecting user names and addresses located in separate tables is a common functionality of a database. A view can be set up to query this information in one table-like result set.
Users
-
Users are the security objects of the database. To keep data safe from unwanted viewers, database administrators give access to users defined in SQL Server. User security can be lenient, giving users open access to the whole database. Administrators can also give strict access by limiting the queries and tables a user is allowed to view.
Functions
-
Functions are similar to ordinary coding. Similar to a compiler function, this database object crunches numbers or provides a way to return a commonly needed result. For instance, if a common need in a database is to add two numbers, a function is used to in a stored procedure to add the numbers and return a result. This saves the programmer time by calling the function rather than coding the process multiple times.
-