How to insert two rows in one column with same id, different cultureId and in different Languages?
I have a table Culture, Companies and CompaniesLocale. In Culture table i have CultureId, CultureCode and DisplayName , in Companies i have CompanyID, Name and in CompaniesLocale I have CompanyID, CultureId, Name. I inserted to languages in culture table English and German. Now When i create a new company how i am going to insert into CompaniesLocale the same Name that is created in Companies but as described in different language(I Choose German but i can be maybe a Cyrillic. I want the new company to be added first to Companies then in CompaniesLocale with the same COmpanyId but the proper CultureId for开发者_StackOverflow the language. Is that possible?
something like insert into CompanyLocal(CompanyId, CultureId, Name) values (1, 1, 'spreken zie deutch')
Basically, I can see two approaches.
Two inserts. First insert a record with the base locale name into
Company
, get the newCompanyID
, then insert the rest of the names intoCompanyLocale
using the obtainedCompanyID
. This assumes there's a triggerON Company FOR INSERT
which adds the base locale name toCompanyLocale
.One insert. Insert all the names into
CompanyLocale
with emptyCompanyID
values. This also assumes using a trigger, this time it'sON CompanyLocale FOR INSERT
. The trigger inserts a new record intoCompany
, gets the new id and updates it for the newly insertedCompanyLocale
records. Also this assumes that the foreign key columnCompanyLocale.CompanyID
, which referencesCompany.ID
, must allow NULL values. (With the first approach I think it can be prohibited from getting NULLs.)
精彩评论