473,405 Members | 2,176 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,405 software developers and data experts.

Database design - enforcing referential integrity on control tables? (sql server and asp 3.0)

Tables:
=====

User
------
ID
Name
NationID
StateID

Nation
-------
ID
Nation

State
-----
ID

Question:
Should an asp database solution enfore referential integrity on control
tables like:

- country
- State

....in a primary Website User Table [Users]?

Or,

Should these be hard-coded into the web page and simply inserted into the
Piimary [User] Table:

User
----
ID
Name
Nation
State

Why do I ask?
----------------
By enforcing a relationship between the tables I am creating extra work for
future stored procedures and allow for possible errors when inserting a new
registrant
into my system if for some reason one of the control table values was
deleted without cascading it to the Primary?

Appreciate any advice on this scenario...

Thanks
Jason
Jul 19 '05 #1
2 2225
My suggestion would be to include a boolean field in your state and country
tables to control whether they are selectable or not. When you select from
those tables to display them to the end user then select only where the
boolean is set to whichever you regard as "selectable". Then disallow any
dba's/what-have-you from being able to delete entries from the state/country
tables. Maybe make a tiny web interface to allow them to set the boolean flag.

This way you keep critical user data in the system but can also "remove" a
country/state as a selectable option for future customers/users.

If you decide not to have referential intergity on these tables (in order to
keep the all-important user data) then I would suggest using LEFT OUTER JOINs
in retrieveing the information, in that manner you would receive valid
state/country values for the users that still had valid assignments, but
would eceive nulls for users that did not. If you used an inner join you
wouldn't receive those users' data back because the data ould not match the
keys in the accompanying state/country tables.

-T

"ja***@catamaranco.com" wrote:
Tables:
=====

User
------
ID
Name
NationID
StateID

Nation
-------
ID
Nation

State
-----
ID

Question:
Should an asp database solution enfore referential integrity on control
tables like:

- country
- State

....in a primary Website User Table [Users]?

Or,

Should these be hard-coded into the web page and simply inserted into the
Piimary [User] Table:

User
----
ID
Name
Nation
State

Why do I ask?
----------------
By enforcing a relationship between the tables I am creating extra work for
future stored procedures and allow for possible errors when inserting a new
registrant
into my system if for some reason one of the control table values was
deleted without cascading it to the Primary?

Appreciate any advice on this scenario...

Thanks
Jason

Jul 19 '05 #2
That is an interesting solution.... In other words, never 'delete' the
record - merely change the 'displayStatus'.....

Surely this premise should then be used for each and every lookup table
which will have REF INT enabled?

Do you use this solution yourself in all your applications?

Finally, I have only recently mastered the INNER JOIN in sql server:

Example:
CREATE Procedure spr_GetUserSelections
@u_ID int

As
set nocount on
Select *
FROM t_user
INNER JOIN Source ON
t_user.u_SourceID = Source.SourceID
INNER JOIN YachtPlacement ON
t_user.u_YachtPlacementID = YachtPlacement.YppID
INNER JOIN Broker ON
t_user.u_BrokerID = Broker.BrokerID
INNER JOIN State ON
t_user.u_StateID = State.StateID
INNER JOIN Nation ON
t_user.u_NationID = Nation.NationID
WHERE t_user.u_ID=@u_ID

return
GO
....Is it possible to adjust the above to OUTER JOINS without affecting the
results...I am slightly confused on when to use one or the other?

Many thanks for your advice...I would never have thought of thought of that
solution in relation to Ref Integrity (ie Bln values)

- Jason

Jul 19 '05 #3

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

Similar topics

0
by: CR | last post by:
To check out stored procs that are under VSS control via my client machine using .NET, I believe I need to change the Options - Database Tools - Server Explorer - STored Procedures - Enable Version...
4
by: craig | last post by:
I have a question about database design that I think some of the more experienced developers might be able to answer... Early on in the development of the DB for a project we are working on, the...
1
by: HGT | last post by:
Hello all, I am currently on a project which the source data come into the databases is always dirty (not surprisingly); however, due to the design of the database, it is very difficult to...
0
by: Rick Gamble | last post by:
I'm in the process of moving ASPNETDB.MDF's security related tables and SP's to SQL Server 2005 and am wondering about the best practice for this task. Are there existing scripts I could run to...
2
by: kai | last post by:
Hi, I use ASP.NET 2.0 and SQL Server 2005. I try to create calendar control which loads all the holidays from a SQL Server 2005 table, and on the calendar , all the holidays will displayed. I saw...
0
by: priyanka s | last post by:
i want to make database connection with "ole db provider for sql server" without using the wizard and then want to use dll file function to insert data getting from remote server...is ther any link...
3
by: Wayne | last post by:
I've inadvertently placed this post in another similar newgroup, and I apologise if you get it twice. I'm building a database that consists of frontend and backend. Some of the lookup tables...
2
by: s14m27 | last post by:
Hi... I have tried displaying images in datagridview control from sqlserver 2000 where i have the path to the images.I could do it column-wise using the DataGridViewImageColumn.Could someone help...
0
by: amazingpeople | last post by:
I have a winform with one pictureBOx and one datanavigator control. I want to bind them to Northwind Employees table(Photo column) with the following code. I can see the images and can navigate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
tracyyun
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...
0
agi2029
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 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.