Chapter 7: Working with Data | 185 |
Adding Tables
The database itself will hold data for customers, orders, and order details that we introduced in the preceding chapter. The data will be held in tables that we’ll create in this section. In later sections, I’ll show you how to perform Create, Read, Update, and Delete (CRUD) operations on this data. Right now, you’ll learn how to create the tables.
To create a table,
The Table Designer allows you to add columns and configure the data type (such as integer, date, float, or character) and other details of each column and the table. Figure
NOTE
Databases, such as SQL Server, have their own type system, which doesn’t always match the .NET type system perfectly. That said, there are types that match very well; for instance, a SQL int is the same as a C# int or VB Integer. A SQL nvarchar(50) can be matched with a C# string or VB String. However, the nvarchar is limited to
50 characters, or whatever length is specified in parentheses, but the C# string and VB String don’t have a specified size. A full discussion of SQL types is out of scope, but you should be aware that there are differences between SQL and .NET types.