Head A C # Chinese version (PAGE20)

Source: Internet
Author: User
Tags integer unique id

Create a datasheet for your contact list we have a database, and now we need to store information in it. But, in fact, our information needs to be put into a data table, a data structure that the database uses to store every bit of data. For our applications, we create a data table called "people" to store all the contact information. 1 Add a data table to the CONTACTDB database.

Right-click Tables in the Database browser and select Addnewtable. This opens a window that lets you define the data columns in the data table you just created.

Now we need to add a data column to our datasheet. First, let's add a data column called ContactID to the new people datasheet so that each contact record has a unique ID. 2 Add the ContactID data column to the People datasheet type "ContactID" in the Column Name field and select int in the data type Drop-down list. Be sure to reverse the Allow blank check box.

Finally, we use it as the primary key for our datasheet. Select the ContactID data column you just created and click the Primary Key button. This tells the database that each entry will have a primary key entry.

Q: What is the data column again? A: The data column is a field inside the database. So in the people database, you might have FirstName and LastName data columns. It always has a data type, such as String or date or bool. Q: Why do we need to contactid data columns? A: For the vast majority of databases, having a unique ID would be helpful. Because we want to store contact information for each person, we decided to create a data column for it and call it ContactID. Q: What does the int in the data type mean? A: The data type tells the database what type of information each data column expects. int represents integer, which is an integer. So ContactID data columns will store integers. Q: There are too many things. Am I supposed to understand it all? A: No, you can't understand it all right now. Focus on the basic steps and we'll spend more time on the database in the following chapters of this book. If you are eager to learn more now, you can always pick up headfirstsql to read with this book.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.