Noddy is a question about sql server relationships between two tables. Can you clarify?

apologize for the stupid question, but there you go.

Sql server tables 2 Order and order A client can have only one order.

When using the Sql server diagram and you want to create a connection between the client. Customer and order. Client ID, in which direction are you dragging the arrow? From customer to order or from order to customer?

Generally speaking, it matters how you do it? Where can I read about this? Or you can clarify this. Thank!

+3
source share
3 answers

The customer.customerID field must be the primary key for the customer table.

Then it doesn’t matter how you drag the arrow. SQLServer is smart enough to figure this out.

, ... "" ( "" ). , SQLServer.

+1

, LEFT JOIN

SELECT *
FROM Customer c LEFT JOIN
Order o ON c.CustomerID = o.CustomerID

, .

, FOREIGN KEY

0

foreign key Order.

, ( foreign key) ( primary key / unique key).

However, the only reason this matters is how you drag the arrow based on what the tool you make allows you to do

In the end, you create the foreign key relationshipfrom table Orderin the table Customerin the columnCustomerId

0
source

Source: https://habr.com/ru/post/1771638/


All Articles