Hello,
I have a problem with foreign key. What I want to do is , have one foreign key referencing in two different tables! I have created three tables:
create table University(
UniversityID int not null,
Name nvarchar(50),
.....
.....
.....
primary key(UniversityI D )
);
create table Person(
PersonID int not null,
Name nvarchar(50),
.....
.....
.....
primary key(PersonID )
);
create table Borrower(
BorrowerID int not null,
Name nvarchar(50),
MemberName int,
.....
.....
.....
primary key(BorrowerID )
foreign key(MemberName) reference University,
foreign key(MemberName) reference Person,
);
So I want to have one column (in my example MemeberName) which referencing in two different tables. How can I do that??
4 1341 Motoma 3,237
Recognized Expert Specialist
I am not entirely sure what you are trying to accomplish, could you please reword you question a little?
I am not entirely sure what you are trying to accomplish, could you please reword you question a little?
Ok, Sorry for that. Well, I have created three tables University, Person and Borrower. What I want to do is to have one column in table Borrower (lets say with name MemberId) which will be foreign key referencing together in the other two tables.
For example I gave the below syntax in SQL Server but it does not work:
create table Borrower(
BorrowerID .............,
............... ......,
............... ........,
............... .........., foreign key (MemberID) references University,
foreign key (MemberID) references Person
);
Motoma 3,237
Recognized Expert Specialist
So you want the key to exist in either one of the tables? I'm not quite sure of the interaction you are looking for.
So you want the key to exist in either one of the tables? I'm not quite sure of the interaction you are looking for.
ok I see. I will try to find another way. thanks
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rowan |
last post by:
Hello,
I am having a problem with a join. Either I am just not seeing the
obvious, it isn't possible, or I need to use a different approach. I
have an application with a vsflexgrid that needs to display the
following:
filenumber, BL, Container_BL, BL_HBL, HBL, Container_HBL
The tables look like:
|
by: Patrick Reilly |
last post by:
I am trying to implement a better method than I already have to document
database schemas with XML, and use XSLT to both generate database DDL
statements (CREATE TABLE, etc) and to transform to HTML for documentation
purposes. In particular I want XSLT to transform to HTML so that my XML
documents can be "live", doing the transform in the browser.
In the new system a very short XML document looks like:
<database>
<table id="PROVIDER">
|
by: heroe |
last post by:
Hello *,
i write you with an urgent problem. I would like to create forign keys
to datetime field, but it doesn't seem to work. I get Can't create table
'.\sampleDB\student_module.frm' (errno: 150) error.
the tables look like
CREATE TABLE IF NOT EXISTS sampleDB.student (
student.from1 DATETIME not null,
student.from2 DATETIME not null,
|
by: Martin Hart |
last post by:
Hi,
postgresql 7.4beta4 on linux
and postgresql 7.3.4 on linux
We have a database that we routinely backup using "pg_dump -a"
We have to do this (dump the data only) because of various characteristics of
the database (e.g. the dump file tries to create fks to tables that it hasn't
created yet if we export schema + data).
|
by: Bri |
last post by:
Greetings,
I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record is entered, either from a form or
from the table view of the table, when the record gets saved it
immediately displays #DELETED# in all of the fields. However, if I close
the form or table view and reopen the record has in fact been inserted.
The...
| |
by: Jean-Yves |
last post by:
Hi.
I have a weird problem when I update my database.
I am using SQL Server 2000. In my VB.NET application I used Web Services for
insert, update, delete.
I have a relation between 2 tables in my database.
I use dataset to transport data to and from the server.
I use native sqlclient provider.
I have .NET Framework 1.1
I use reflexion to create objects: SqlDataAdapter, SqlCommand. All this
using interfaces like IDBDataAdapter,...
|
by: clickon |
last post by:
I am using ASP.net 2.0 and trying to take advantage of the updated data
editing facilities provided through the SQLDataSource control and the
DetailsView control. The data is a record from a customer complaints table
and one of the fields on the DetailsView control is called ComplaintType.
The field is a template field and in insert mode and edit mode i have used a
DropDownList control bound to a set of keys and values in a ComplaintTypes...
|
by: Justin |
last post by:
I can attach my code if anyone wants to see it however I'll try to ask my
question with some mark up code first.
I'm having a problem terminating my process while using DoEvents. For
example:
Button.text = start
If button.text = start then
button.text = stop
|
by: Adrock952 |
last post by:
I am trying to create my tables where if i delete/update a record from one table, all the other tables are affected by deleting/updating any records that reference the original record.
For example, if i delete/update a record from the employee table, the other tables that are referenced to it will be updated/deleted
Here is the database create SQL i have
CREATE TABLE Employee (
ssn NUMBER (4) PRIMARY KEY,
salary ...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |