在sql server问题中创建表关系 [英] creating tables relationship in sql server questions
问题描述
老乡们,
我被困了,我有两个问题。首先,如果表关系是正确的。其次,我想允许一个部件可以用于许多型号/引擎。例如,2001年本田,雅阁和2002年本田雅阁发动机1.6可以拥有相同的交流发电机。
VehicleType
-ID
-Name
制作
-ID
-Yar
-Name
-VehicleTypeID
型号
-ID
-MakeID
-Name
引擎
-ID
-ModelID
-Name
产品
-ID
-CategoryID
-Name
-Description
ProductEngine
-ProductID
-EngineID
类别
-ID
-Name
Hi fellows,
I am stuck, I have two questions. First, if the tables relationships are right. Second,I want to allow a part can be used for many models/engines. For instance, 2001 Honda, Accord and 2002 Honda accord Engines 1.6 can have the same alternator.
VehicleType
-ID
-Name
Make
-ID
-Year
-Name
-VehicleTypeID
Model
-ID
-MakeID
-Name
Engine
-ID
-ModelID
-Name
Product
-ID
-CategoryID
-Name
-Description
ProductEngine
-ProductID
-EngineID
Category
-ID
-Name
推荐答案
我们无法真正回答这个问题 - 我们不知道您已经建立或将要建立什么关系。
我们可以假设存在一个与该名称存在关系,但是那不告诉你这是什么类型的关系 - 这很重要。例如,一对多的关系与一对一的关系不同。
我们也不确切知道你要做什么数据:
例如,2013款本田雅阁1600可能与2014款本田雅阁1600具有相同或不同的发动机,但发动机可以共用相同的交流发电机,即使它们不同,或者有不同的交流发电机,即使它们是相同的。在你的系统中这很重要吗?我不知道,我不知道你的项目需要什么。
我建议你坐下来尝试一些样本数据,包括你需要的每一个变种接受并检查你设计的方案是否可以容纳它 - 这是PITA的工作,但它必须从一开始就是正确的,因为这里的任何错误或遗漏都会产生深远的影响。
可能需要将汽车视为一组子组件,每个子组件都由更多的子组件组成:因此L模型的车身装饰子组件可以类似 - 但与GL型号的车身装饰子装配不同,即使它们共用相同的发动机。
We can't really answer that based on that - we have no idea what relationships you have established, or are going to establish.
We can assume a relationship exists from the name, but that doesn't tell us what type of relationship it is - and that's important. A one-to-many relationship is not the same as a one-to-one for example.
We also don't know exactly what you are trying to do with the data:
For example, a 2013 Honda Accord 1600 could have the same or a different engine to the 2014 Honda Accord 1600, but the engines could share the same alternator, even if they are different, or have different alternators, even if they are the same. Is that important in your system? I don't know, I have no idea what your project entails.
I'd suggest that you sit down and try some sample data, including every variation you need to accept and check that the scheme you have designed can accommodate it - it's a PITA job, but it needs to be right from the beginning as any mistake or omission here have have far reaching consequences.
Probably, you need to consider the cars as a set of sub-assemblies, each of which is comprised of further sub-assemblies: so that the body trim sub-assembly for a "L" model can be similar-but-different from the body trim sub-assembly for a "GL" model, even if they share identical engines.
这篇关于在sql server问题中创建表关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!