需要有关MS SQL Solution的帮助 [英] Need help on MS SQL Solution

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

问题描述

我有三个表,例如SCHOOL,ORIENTATION和SUBJECTS。

表格具有以下属性

  CREATE   TABLE  [dbo]。[SCHOOL](
[ID_chool] [ int ] IDENTITY 1 1 NOT NULL
[SchoolName] [ nvarchar ]( 50 NOT NULL
[AcademicYear] [ nvarchar ]( 15 NOT NULL
[地址] [ nvarchar ]( 50 NOT NULL
[ID_Person] [ int ] NULL
[ID_Municipality] [ int ] NOT NULL
CONSTRAINT [PK_SCHOOL] PRIMARY KEY CLUSTERED



  CREATE   TABLE  [dbo]。[ORIENTATION](
[ID_Orientation] [ int ] IDENTITY 1 1 NOT NULL
[ID_School] [ int ] NOT NULL
[OrientationName] [ nvarchar ]( 50 NULL
CONSTRAINT [PK_ORIENTATION] PRIMARY < span class =code-keyword> KEY CLUSTERED



和第三个表

  CREATE   TABLE  [dbo]。[SUBJECT ](
[ID_Subject] [ int ] IDENTITY 1 1 NOT NULL
[SubjectName] [ nvarchar ]( 50 NOT NULL
[ID_Orientation] [ int ] NOT NULL
CONSTRAINT [PK_SUBJECT] PRIMARY KEY CLUSTERED





问题是小学没有ORIENTATIONS,所以他们不需要OrientationName,只有中学需要OrientationName 。

如何解决这个问题,以便我可以为小学注册科目。

P.S.我的项目有15个表,但我遇到了这个问题并且无法自己解决这个问题。

提前感谢您的回复。

干杯。

解决方案

这似乎不是孤立的问题。



为什么缺乏方向导致问题?唯一包含学校和方向的表是方向表 - 所以只是不要创建记录!

然后在Subject表的ID_Orientation字段中允许空值并且你是固定的,不是'你呢?



如果没有数据来确切地指出问题是什么,很难弄清楚为什么这会给你带来困难! :笑:

I have three tables like SCHOOL, ORIENTATION and SUBJECTS.
The tables have the following attributes

CREATE TABLE [dbo].[SCHOOL](
	[ID_chool] [int] IDENTITY(1,1) NOT NULL,
	[SchoolName] [nvarchar](50) NOT NULL,
	[AcademicYear] [nvarchar](15) NOT NULL,
	[Address] [nvarchar](50) NOT NULL,
	[ID_Person] [int] NOT NULL,
	[ID_Municipality] [int] NOT NULL,
 CONSTRAINT [PK_SCHOOL] PRIMARY KEY CLUSTERED 


CREATE TABLE [dbo].[ORIENTATION](
	[ID_Orientation] [int] IDENTITY(1,1) NOT NULL,
	[ID_School] [int] NOT NULL,
	[OrientationName] [nvarchar](50) NULL,
 CONSTRAINT [PK_ORIENTATION] PRIMARY KEY CLUSTERED


And the third table

CREATE TABLE [dbo].[SUBJECT](
	[ID_Subject] [int] IDENTITY(1,1) NOT NULL,
	[SubjectName] [nvarchar](50) NOT NULL,
	[ID_Orientation] [int] NOT NULL,
 CONSTRAINT [PK_SUBJECT] PRIMARY KEY CLUSTERED 



The problem is that the primary schools don't have ORIENTATIONS, so they don't need an OrientationName, only the secondary schools need an OrientationName.
How to solve this problem so I can register the subjects for primary schools.
P.S. My project has 15 tables, but I'm stuck in this problem and can't solve this problem by myself.
Thank you in advance for your reply.
Cheers.

解决方案

That doesn't seem to be a problem in isolation.

Why would the lack of "orientation" cause a problem? The only table which includes a school and an orientation is the orientation table - so just don't create a record!
Then allow nulls in the ID_Orientation field of the Subject table and you are fixed, aren't you?

Without data to indicate exactly what the problem is it's hard to work out why this is causing you difficulties! :laugh:


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

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