Database Tables  «Prev  Next»

Lesson 4 Creating databases, part 1
ObjectiveDescribe elements of a basic database.

Elements of a database in SQL-Server 2022.

As a SQL Developer working with SQL Server 2022, you'll interact with a variety of elements that make up the database system. These elements are crucial for the organization, manipulation, and retrieval of data. Here's an overview of the key elements of a database in SQL Server 2022:
  1. Databases: The fundamental container for data in SQL Server, a database is an organized collection of data that can be accessed, managed, and updated. Each database in SQL Server is isolated from others and can contain multiple objects like tables, views, stored procedures, etc.
  2. Tables: Tables are the core structure where data is stored in a database. They are organized into rows and columns, with each row representing a unique record and each column representing a field within the record. Tables define the schema for data storage and are essential for data organization and integrity
  3. Columns (Fields): Columns, or fields, represent the individual data points within a table. Each column has a specific data type that dictates the kind of data it can store, such as integers, strings, dates, etc. Columns also define constraints and rules for the data, such as NOT NULL, UNIQUE, CHECK, and more, to ensure data integrity.
  4. Rows (Records): Rows, or records, in a table represent individual data entries. Each row in a table has a unique identifier, often referred to as a primary key, which distinguishes it from other rows.
  5. Primary Keys: A primary key is a unique identifier for a row within a table. It ensures that each record can be uniquely identified, which is essential for relationships between tables and data integrity.
  6. Foreign Keys: Foreign keys are used to establish relationships between tables. A foreign key in one table points to a primary key in another, creating a link between the records. This is essential for enforcing referential integrity and relational database principles.
  7. Indexes: Indexes are used to speed up the retrieval of data from a database by providing quick access to rows in a table. An index is created on a column or a combination of columns in a table.
  8. Views: Views are virtual tables that are defined by a SQL query. They provide a way to present data in a specific format or aggregation without altering the underlying tables. Views can simplify complex queries, enhance security, and abstract the underlying database structure from users.
  9. Stored Procedures: Stored procedures are a collection of SQL statements that are compiled and stored in the database. They can be executed with various parameters to perform complex operations, enforce business logic, and improve performance by reducing network traffic and reusing code.
  10. Triggers: Triggers are special types of stored procedures that automatically execute in response to specific events on a particular table or view, such as insert, update, or delete actions. They are used to enforce business rules and data integrity.
  11. Schemas: Schemas in SQL Server provide a way to logically group database objects such as tables, views, and stored procedures. They can be used to organize database objects into distinct namespaces, making it easier to manage permissions and maintain the database.
  12. User-defined Functions (UDFs): UDFs are functions created by users to encapsulate frequently used calculations or operations. They can accept parameters, perform actions, and return the result. UDFs can be used in SQL queries, stored procedures, and triggers.
  13. Transactions: Transactions in SQL Server are sequences of operations performed as a single logical unit of work. They ensure data integrity by allowing multiple operations to be executed while maintaining the database in a consistent state. Transactions follow the ACID properties (Atomicity, Consistency, Isolation, Durability) to ensure data reliability.

These elements, when combined, provide a robust framework for storing, retrieving, and manipulating data within SQL Server 2022, allowing for efficient data management and analysis in various applications.

Database Owner
Database Owner


Before you can create any objects to contain or manage your data, you must create a database to act as a container for those objects. In this lesson, you will create a database that we will build on during the rest of this course.
The biggest consideration in creating a database is its size. This is the maximum amount of disk space the database will consume. One of the new features of SQL Server 7 is its ability to allocate space dynamically for databases. I highly recommend this, it is better to have SQL Server allocate more space than necessary than for you to receive a critical error indicating that you ran out of disk space when you are trying to save data.
Along with a database is an object that works "behind the scenes" called a transaction log. A transaction log is used to store data when a query is managed within a transaction. The transaction log preserves the state of the data at the point when the transaction is started. Transactions are discussed in another course in this series. For now, it is just important to know that the transaction log exists.
To create a database, use the Transact-SQL statement CREATE DATABASE. This is described in an upcoming lesson. You can also create a database by clicking the name of your server in the Enterprise Manager. From the Action menu, select New, then select Database to display the Database Properties dialog, illustrated below.
Database properties dialog
Database properties dialog

In the next lesson, you will learn how to use Transact-SQL to create a database.
SEMrush Software