- [Instructor] Before we can start storing information in our database, we need to understand a little bit about how tables are structured and the types of data that can be stored. Tables are made up of vertical columns and horizontal rows. Each row in the table will store information about a single item that we want to keep track of. These are called records, and you can think of the records as nouns, the people, places, or things in the database. Columns in the table are called fields, and they'll store the attributes about each of our records.
Each column in the table can be thought of as the adjectives, the descriptors that define the unique components of each record. Here is an example. Let's suppose that we have a table to store information about our customers. Each row in the table will represent a single customer. Each column in the table will define their attributes, such as their name, their birthday, their favorite color, and so on. All of the tables in your SQL Server databases will follow this basic structure. So to create a table, we simply define the purpose for each column.
And since each column will store the same piece of information about all of the records, we'll want to also define the type of data that'll be stored, whether it'll be a text value, a number, or a date or something else. In SQL Server, we have a number of different data types that we can choose from, and they can get pretty specific. I'll just touch on some of the most common types here. When storing text-based data, we can choose the char data type to store basic text or nchar if we need to store characters that appear in the extended Unicode character set, such as those used in the Cyrillic or Kanji languages.
Char and nchar allow the storage of a specific number of characters, which you'll see noted inside of the parentheses. And you can change this value to whatever number suits your needs. For data that'll have a variable length for each record, we can choose varchar or nvarchar and specify a number of maximum length instead. For numerical data, we'll often choose between an integer data type that'll only allow the storage of whole numbers within a range, such as a tinyint or just plain int. Or we can choose a data type that'll allow fractions, such as decimal or float.
Finally, there are specialized data types that'll store date, currency, or geographic location data, among others. So no matter what type of information you're trying to store in the database, you're sure to find a data type within SQL Server that'll do the job.
▶️ DTube
▶️ IPFS