| |

VerySource

 Forgot password?
 Register
Search
View: 810|Reply: 6

Does sqlserver have anything like union foreign keys

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-10 10:00:01
| Show all posts |Read mode
such as:
I have three tables, the product table, the enterprise table, and the publication activity table. The user has to comment on these three tables that are not related and have different structures, so I have a review table.
Comment form details:
F_Id int identiy (1,1), primary key
Entity_Id int, or product ID, or enterprise ID, or publishing activity ID ------- Question?
F_Bound tinyint, the scope of the review, is the product, business or event
User_Id varchar (20), user ID
F_Title varchar (50), comment title
F_DateTime datetime, comment time
F_Content varchar (500)

How can I set the foreign key of this table? If a foreign key is set, there is a master-slave table relationship, but the Entity_Id does not correspond to only one table. How to make it a foreign key for three tables ???????
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 Japan

Post time: 2020-6-1 14:30:04
| Show all posts
Entity_Id int, or product ID, or enterprise ID, or release event ID
Entity_Type int, or 1- commodity table, 2- enterprise table, 3- release activity table

--Can I add a field?
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-6-1 23:15:02
| Show all posts
Doesn't seem to work

To achieve this, it can be verified by trigger, insert or update
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-3 20:45:01
| Show all posts
fanfan1980
 
 
   Entity_Id int, or product ID, or enterprise ID, or release event ID
Entity_Type int, or 1- commodity table, 2- enterprise table, 3- release activity table

--Can I add a field?
____________________________________________________________________________
Of course, but there is still no relationship. My table already has such a field.
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-4 08:15:01
| Show all posts
wgfxman
 
 
   Doesn't seem to work

To achieve this, it can be verified by trigger, insert or update
_______________________________________________________________________
Really? Can this only be done? ? I'm so disappointed. I want to listen to the opinions of the authorities.
Does MS have no scientific plan
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-4 23:00:01
| Show all posts
If it doesn’t work, I don’t have any constraints or write it.
Reply

Use magic Report

0

Threads

20

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-6-13 11:15:01
| Show all posts
Establish relationships with the Entity_Id of the comment table on the other three tables
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list