有关IDENTITY列的帮助. [英] help with IDENTITY columns..

查看:89
本文介绍了有关IDENTITY列的帮助.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我正在尝试在复合主键中使用IDENTITY列...假设我有一个关系

    Artists(#ArtistID,Artist Name)

和另一个关系

   曲目(#TrackID,#ArtistID,曲目名称,流派)

我认为由于身份列的关系,每个艺术家都有很多曲目"的关系将是正确的...

#TrackID即使与#ArtistID结合使用也始终是唯一的,因此每个艺术家都有很多曲目",但不是每个艺术家都可以遇到每个曲目"
(如果#TrackID不是"IDENTITY"列),那是错误的,对吧?
它仅有助于在一侧建立关系..每个艺术家都有许多足迹,但每个轨迹只能在一个艺术家中得到满足"

请解释

Hi everyone !
I''m trying to get the sense of using IDENTITY columns in composite primary key... Suppose I have a relation

    Artists(#ArtistID,Artist Name)

and another relation

    Tracks(#TrackID, #ArtistID, Track Name, Genre)

I think that due to identity columns the relation "Each artist has many tracks" would be right...

#TrackID is always unique even in combination with #ArtistID, so "each Artist has many tracks", but not "each track could be met in many artists"
(if #TrackID wasn''t IDENTITY column) - that would be wrong, right????

it helps to build a relation in one side only .."EACH ARTIST HAS MANY TRACKS, BUT EACH TRACK COULD BE MET ONLY IN ONE ARTIST"

explain please

推荐答案

唯一ID仅标识记录.您认为一首歌只能归于一位歌手的假设是有缺陷的,因为许多歌手可能会覆盖同一首歌.例如,我至少知道十几个版本的标题天空中的幽灵骑士,其中一些版本来自同一位艺术家,但其中许多来自不同的艺术家.

唯一可以称为唯一的是给定艺术家的专辑.

我认为您必须坐下来重新考虑数据库组织.
The unique ID merely identifies the record. Your assumption that one song can only be attributed to a single artist is flawed because many artists might cover the same song. For instance, I know of at least a dozen versions of the title Ghost Riders In The Sky, and some of those versions are from the same artist, but many of them are by different artists.

The only thing that can be called unique is an album by a given artist.

I think you have to sit down and re-think your database organization.


您可以看看^ ]数据库模型作为入门.
如果您想变得挑剔,这也是有缺陷的.
它没有考虑到艺术家和乐队及其成员不是同一回事.它也没有考虑到有时艺术家会更改他/她的艺术家名称,但是您仍然希望将专辑一起列出.

但这是一个开始.
You can have a look at this[^] database model as a starter.
This one is also flawed if you want to be picky.
It doesn''t take into account that an artist and a band with its members aren''t the same thing. It also doesn''t take into account that sometimes an artist changes his/hers artist name, but you would still like to have the albums listed together.

But it''s a starter.


这篇关于有关IDENTITY列的帮助.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆