473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SQL - Foreign key with references of multiple tables with same primary key field

I want to create a table with

member id(primary key for Students,faculty and staff [Tables])

and now i want to create issues[Tables] with foreign key as member id
but in references i could not able to pass on reference as or
condition for students, faculty and staff.

Thank You,
Chirag

Apr 9 '07 #1
3 19154
Chirag wrote:
I want to create a table with

member id(primary key for Students,faculty and staff [Tables])

and now i want to create issues[Tables] with foreign key as member id
but in references i could not able to pass on reference as or
condition for students, faculty and staff.
Create a Members table, then have all the other tables reference it.
Apr 9 '07 #2
On Apr 9, 9:48 am, "Chirag" <chirag.dpa...@gmail.comwrote:
I want to create a table with

member id(primary key for Students,faculty and staff [Tables])

and now i want to create issues[Tables] with foreign key as member id
but in references i could not able to pass on reference as or
condition for students, faculty and staff.

Thank You,
Chirag
Two options

1. Create multiple member tables
member_student,member_faculty,member_staff and
issues_student,issues_faculty,issues_staff

2. Create a new column called flag in both the tables like
Create table member ( memberid iNT, Flag Char(1) --S - Student,
F- Faculty, T - Staff)

Primary Key (flag,memberid)
Create table Issues (memberid INT, Flag Char(1) -- S - Student, F-
Faculty, T- Staff)
Primary Key (flag,memberid)

Now Reference two tables with flag and memberid.

If you want to refernce member table with student,faculty,staff you
need to handle in trigger

Apr 9 '07 #3
On Apr 8, 11:34 pm, "M A Srinivas" <masri...@gmail.comwrote:
On Apr 9, 9:48 am, "Chirag" <chirag.dpa...@gmail.comwrote:
I want to create a table with
member id(primary key for Students,faculty and staff [Tables])
and now i want to create issues[Tables] with foreign key as member id
but in references i could not able to pass on reference as or
condition for students, faculty and staff.
Thank You,
Chirag

Two options

1. Create multiple member tables
member_student,member_faculty,member_staff and
issues_student,issues_faculty,issues_staff

2. Create a new column called flag in both the tables like
Create table member ( memberid iNT, Flag Char(1) --S - Student,
F- Faculty, T - Staff)

Primary Key (flag,memberid)
Create table Issues (memberid INT, Flag Char(1) -- S - Student, F-
Faculty, T- Staff)
Primary Key (flag,memberid)

Now Reference two tables with flag and memberid.

If you want to refernce member table with student,faculty,staff you
need to handle in trigger
Hi,
cant be create one foreign key at column level and others at table
level

Apr 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jay | last post by:
Hi everyone ! I hope someone will be able to help me with this problem. I currently have several tables in MySQL database. Below is my table structures. (Data type for each fields are...
1
by: cr113 | last post by:
Suppose you have the following 2 database tables: Table1 - primary key = Field1 Field1 Field2 a 1 b 2 c 2
4
by: Omey Samaroo | last post by:
I am using Employee_Number as a primary field in one table and in another table I have a field with the same name that it references in a one to many relationship. How do I change the primary field...
13
by: ricky.agrawal | last post by:
I'm really not sure how to go about this in Access. What I've created is a table for each location. Those tables are identical in format but different in information. The tables are named after...
6
by: ApexData | last post by:
I have 2 tables: Table1 and Table2. Neither one has a primary key because each table will only have 1-record. My form is a SingleForm unbound with tabs (my desire here). Using this form, in...
1
by: Magnus | last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables). http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx In the famous Customer/Order example, I'm getting referential...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
6
by: ravichoudhari | last post by:
i came accross requirement of multiple foreign keys in a table referencing the same primary key another table. i created the table relations using the relations editor in access. even though i...
3
by: DeanL | last post by:
Hi guys, Does anyone know of a way to create multiple tables using information stored in one table? I have a table with 4 columns (TableName, ColumnName, DataType, DataSize) and wanted to know...
1
by: mtdew4243 | last post by:
I’m working on my first major project using MS Access. MS Excel had been the program of choice before this. I work in the Operations department for a distribution company. We track daily...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.