Confused on Azure SQL Management Portal - Foreign Key
i have 2 tables
accounts (account_id primary key, company_name, etc. etc.)
invoices (inv_no primary key, account_id)
i believe foreign key here account_id in invoices table as there many invoices same account_id accounts table.
i trying set relationship in management portal, however, terminology , interface seems counter-intuitive me, , backwards. if select accounts table select indexes & keys, there button "add foreign key relationship". when click on button ask specify foreign key , shows check box next every field in accounts table select acccount_id, select reference table invoices, try select "reference column" , title shows "primary or unique keys', inv_no displayed. have in reverse and start invoices table select foreign key. me seems backwards , in dependency diagram arrow goes invoices accounts, seems backwards. missing?
i know why management portal allows selection of multiple primary keys, thought disallowed in azure sql, or sql matter?
thank you, joe
hello,
the foreign key column reference column host primary key values in table. based on description, try to create foreign key constraint on invoices table reference column "account_id" in accounts table. should add the foreign key relationship on invoices table rather account table. or can refer following statement:
create table accounts (account_id int primary key, company_name varchar(20), etc..) create table invoices (inv_no int primary key, account_id int foreign key references accounts(account_id))
the dependencies view should follows:
regards,
fanny liu
fanny liu
technet community support
Microsoft Azure > Azure SQL Database
Comments
Post a Comment