开发者

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.

  1. Two inserts. First insert a record with the base locale name into Company, get the new CompanyID, then insert the rest of the names into CompanyLocale using the obtained CompanyID. This assumes there's a trigger ON Company FOR INSERT which adds the base locale name to CompanyLocale.

  2. One insert. Insert all the names into CompanyLocale with empty CompanyID values. This also assumes using a trigger, this time it's ON CompanyLocale FOR INSERT. The trigger inserts a new record into Company, gets the new id and updates it for the newly inserted CompanyLocale records. Also this assumes that the foreign key column CompanyLocale.CompanyID, which references Company.ID, must allow NULL values. (With the first approach I think it can be prohibited from getting NULLs.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜