Tengo una situacion que luce así
La siguiente tabla puede tener foreignkeys de 2 tabls diferentes y no se
como crear o si no se puede crear esa relacion conbinada de 2 tablas
tbTrabajosYMetas
xid, tablecode, code
1, 'mts', 1
1, 'mts', 2
1, 'trb', 1
2, 'trb', 1
Los 3 campos son la llave primaria, tablecode y code son el foreignkey
La segunda tabla
tbMetas
tablecode, code, descripcion, etc
'mts', 1, 'meta1' ..
'mts', 2, 'meta2' ..
La Tercera tabla
tbTrabajos- tablecode y code Es la primaryKey al igual que en la tabla
anterior
tablecode, code, descripcion, hora, etc
'trb', 1, 'trabajo1', ..
'trb', 2, 'trabajo2', .. 2 2111
Lucas Hernandez wrote:
Tengo una situacion que luce así
La siguiente tabla puede tener foreignkeys de 2 tabls diferentes y no se
como crear o si no se puede crear esa relacion conbinada de 2 tablas
tbTrabajosYMetas
xid, tablecode, code
1, 'mts', 1
1, 'mts', 2
1, 'trb', 1
2, 'trb', 1
Los 3 campos son la llave primaria, tablecode y code son el foreignkey
La segunda tabla
tbMetas
tablecode, code, descripcion, etc
'mts', 1, 'meta1' ..
'mts', 2, 'meta2' ..
La Tercera tabla
tbTrabajos- tablecode y code Es la primaryKey al igual que en la tabla
anterior
tablecode, code, descripcion, hora, etc
'trb', 1, 'trabajo1', ..
'trb', 2, 'trabajo2', ..
tbTrabajosSinMetas
xid, code
1, 1
1, 2
tbMetasSinTrabajos
xid, code
1, 1
2, 1
select xid, 'trb' as tablecode, code from tbTrabajosSinMetas
union
select xid, 'mts' as tablecode, code from tbMetasSinTrabajos
Lucas Hernandez (lu******@fuse.net) writes:
Tengo una situacion que luce así
La siguiente tabla puede tener foreignkeys de 2 tabls diferentes y no se
como crear o si no se puede crear esa relacion conbinada de 2 tablas
tbTrabajosYMetas
xid, tablecode, code
1, 'mts', 1
1, 'mts', 2
1, 'trb', 1
2, 'trb', 1
Los 3 campos son la llave primaria, tablecode y code son el foreignkey
La segunda tabla
tbMetas
tablecode, code, descripcion, etc
'mts', 1, 'meta1' ..
'mts', 2, 'meta2' ..
La Tercera tabla
tbTrabajos- tablecode y code Es la primaryKey al igual que en la tabla
anterior
tablecode, code, descripcion, hora, etc
'trb', 1, 'trabajo1', ..
'trb', 2, 'trabajo2', ..
El mejor es de usar dos campos de code in tbTrabajosYMetas, un per
tbTrabajos y un per tbMetas. Con esos non es un problema con
foreignkey. Es también una buena idea de haber un CHECK constraint:
CHECK (code_trabajo IS NOT NULL AND code_meta IS NULL OR
code_trabajo IS NULL AND code_meta IS NOT NULL)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pakkocool |
last post by:
¿Como ganar dinero en internet?
Lee atentamente el siguiente texto, es super interesante y te hara
ganar muchos dolares si sigues las instrucciones y le pones empeño:
Hace unos días que...
|
by: francisco lopez |
last post by:
I hope not sent I twice.
ok here is my problem,
the javascript form validation works perfect during I put a
emaildirection in the <form action:""> comand, like this:
<form...
|
by: Mike Leahy |
last post by:
Hello all,
This question is related to updating tables - is there any way to calculate or
update the values in a column in a table to the values in a field produced by
a query result? An...
|
by: Liber |
last post by:
¿Alguien podría explicarme como enviar mails desde un WindowsForm ?, puedo
hacerlo con un WebForm, pero no se como hacerlo con WindowsForm, podrían
darme un ejemplo.
Gracias,
Saludos, Liber.
|
by: Luis Esteban Valencia |
last post by:
www.isohunt.com
Hagan una busqueda por cualquier cosa y en la lista de resultados hagan
click en una fila y veran como se despliega dinamicamente algo entre 2 filas
con un interesante efecto'
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |