I created a table that contains information about a company. One attribute is their telephone number. A company can have many telephone numbers.
How do I create mul
In a separate table like:
CREATE TABLE Company
(
Id int identity primary key,
Name nvarchar(100) not null UNIQUE --UNIQUE is optional
)
GO
CREATE TABLE CompanyPhones
(
Id int identity primary key,
Phone nvarchar(100) not null,
CompanyId int NOT NULL REFERENCES Company(Id) ON DELETE CASCADE
)
How to use these structures:
SELECT CompanyPhones.Phone
FROM Company
JOIN CompanyPhones
ON Company.Id = CompanyPhones.CompanyId
WHERE Company.Name=N'Horns and Hoogs Ltd.'