一个表与15个表的关系 [英] one table relation to 15 tables

查看:119
本文介绍了一个表与15个表的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我们正在开发一个应用程序.我们是analise数据库.主表与15个表的关系.在emp_no primare键的主表中,其余表为foregen键.我对吗?在我们的应用程序中,当员工登录到应用程序时,基于emp_no登录到员工,只有从所有表中获取员工信息.我们正在asp.net中开发应用程序.

请给我您的宝贵建议.


我们使用的技术是:Csharp,asp.net,badkend sqlServer 2008

Dear All,

we are developing one application. we are analise database . master table relation to 15 tables. in master table in emp_no primare key, remaining tables is foregen key. am i right? in our application login in to employee based on emp_no when employee login to the application onle that employee information get from the all the tables. we are developing application in asp.net.

please give me your valuable suggation .


we are using technologies :Csharp, asp.net,badkend sqlServer 2008

推荐答案

基本思想是正确的,父表具有在其上定义的主(或唯一)键它和子表使用外键约束引用父表.很好的例子: http://www.w3schools.com/sql/sql_foreignkey.asp [
The basic idea is correct, the parent table has a primary (or unique) key defined on it and the child tables reference the parent table with a foreign key constraint. Good examples: http://www.w3schools.com/sql/sql_foreignkey.asp[^]

I didn''t quite understand the other part of the question concerning login. You can create a table (user etc) to define information about the users of your applications and using that table check if the user is valid or not (correct password, username and so on).


建议在SQL级别执行此逻辑.您可以将存储过程编写为:

Recommendation is to execute this logic at SQL level. You can write a stored procedure as:

Create Procedure FetchEmpInfo
@EmpNo Int
AS
SELECT * FROM Employee mast, reftable1 r1, reftable2 r2,....reftable15 r3
WHERE 
mast.Id IN(@Ids) AND
mast.Id = r1.Id AND
mast.Id = r2.Id AND
.....
mast.Id = r15.Id AND


我不明白为什么1个表(主表)与15张桌子有关.

我建议阅读:
了解数据库 [导航表之间的关系 [ Northwind [
I can''t understand why 1 table (master) is related with 15 tables.

I suggest to read:
Understanding databases[^]
Navigating a Relationship between tables[^]

Example database: Northwind[^] is availible to download. Please, study it.


这篇关于一个表与15个表的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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