Use Visual Studio. NET to define database tables
The simplest way to define a database table in Visual Studio. NET is to create a database graph. In this way, you can define all the details in an Editor similar to "WYSIWYG. You only need to expand the corresponding tree in Server Explorer (Server resource manager), right-click the Database Diagrams (Database Diagram) item, and select New Database digoal from the context menu... (creating a database graph ...), to start a new blank graph. When you start a graph for the first time, the system requires you to select a table from the database. You can ignore this dialog box because you have not created any tables. Now, you can start to define your table.
The user solution document in the generated ASP. NET application planning and design contains the information required to define the table. It is usually the best way to learn how to add new records to the system. Sometimes you need to view other schemes such as record updates or even reports to ensure that no other fields are missing. In this example, the "add record" solution is a good reference solution.
For example, the following is a solution for adding a problem:
Add new question
Add a new question record to the system, including the title, date/time, topic ID indicating the category of the question, and question body. You may also need to provide the name and email address of the problem initiator. After a new question is added, a unique integer question ID is returned to the called function.
Important terms are in bold. When reading the solution description, these terms or table names (for example, "problem records" are a good example) often indicate what data needs to be stored. With the above information, you can add a new table in the database graph and define the required columns. The following example details how to add tables to a database graph.
Right-click the graph "surface" and select New Table... (New Table...) from the context menu ...). Enter Questions (problem) as the table name, and click OK to add it to the graph.
In the Questions (problem) Table dialog box, type the field information provided in the preceding solution. For example, Column Name = ID, Data Type = int, Length = 4, and deselect the Allow Nulls check box. Repeat the preceding operations on the remaining parts of the table (see figure 3 ).