Beginning SQL Server 2008 for Developers From Novice to Professional phần 3

8. Sau khi đăng nhập, hãy bắt đầu SQL Server Management Studio bằng cách chọn Bắt đầu ➤ All Programs ➤ Microsoft SQL Server 2008 ➤ SQL Server Management Studio. Bạn sẽ cần phải cư trú trong hộp thoại với tên máy chủ của tiến trình cài đặt. Click vào Browse Để biết thêm, sau đó chọn Công cụ cơ sở dữ liệu và chọn cài đặt. | CHAPTER 3 DATABASE DESIGN AND CREATION 65 To illustrate the one-to-one relationship imagine that in our example bank database there is a table that holds PIN numbers for ATM cards keeping them completely separate from the remainder of the customer records see Figure 3-1 . In most cases there would be one PIN number record for each customer record but there may be exceptions for instance a high-interest deposit account may not have a card and therefore there would be no associated PIN number record. Customer s Bank Account The primary key is the customer number and account type for example Current or Deposit . Customer s Card PIN Number The primary key is the customer number and account type. Figure 3-1. One-to-one relationship One-to-Many Perhaps the most common relationship found in a database is the one-to-many relationship. This is where one master record is linked with zero one or more records in a child table. Using our banking example say we have a customer master record along with any number of associated transaction records. The number of these transaction records could range from none which corresponds to when a customer is new to the bank and hasn t made a deposit or performed a transaction to one or more which corresponds to when there has been an initial deposit in an account and then further deposits or withdrawal transactions after that see Figure 3-2 . Customers The primary key is the customer ID. Account Transactions The primary key is the customer ID and the order number. Figure 3-2. One-to-many relationship You ll see this concept in action again in the customer-to-transactions relationship we ll build for our solution. Many-to-Many Many-to-many is the final relationship type that can exist in a database. This relationship can happen relatively frequently. In this type of relationship zero one or indeed many records in the master table relate to zero one or many records in a child table. An example of a many-to-many relationship might be where a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.