473,549 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2233
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***@catamara nco.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_GetUserSele ctions
@u_ID int

As
set nocount on
Select *
FROM t_user
INNER JOIN Source ON
t_user.u_Source ID = Source.SourceID
INNER JOIN YachtPlacement ON
t_user.u_YachtP lacementID = YachtPlacement. YppID
INNER JOIN Broker ON
t_user.u_Broker ID = Broker.BrokerID
INNER JOIN State ON
t_user.u_StateI D = State.StateID
INNER JOIN Nation ON
t_user.u_Nation ID = 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
1220
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 Control from unselected to selected. Problem is that I can't select it. Our sql server is already setup for VSS/SourceSafe control, and other...
4
482
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 decision was made to use physical deletion of records from the DB rather than logical deletion. This seemed to be working just fine until now. ...
1
1945
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 impose referential integrity (esp. Foreign Keys) on these tables. Am I just not thinking straight? This solution is implemented on multi RDBMS. ...
0
847
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 create these tables and SP's or would I create them myself? Alternately would I be best off DTS'ing them into SQL server 05?
2
5183
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 some code on the Web hard coded holidays, then populate on the calendar. Is it possible to do calendar data binding? Thanks kai
0
1595
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 with proper example...or any help how to do thsi....
3
2643
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 need to reside in the frontend database. The data in the lookup fields that relate to the backend tables will never change, but a descriptor for...
2
2646
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 me out doing the same row-wise and also display the other details corresponding to the image stored in the database. Thank you!!
0
1436
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 through them also thru the datanavigator. But the images are not clear(hazy). can anybody help me out? ...
0
7542
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, 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...
0
7467
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...
0
7736
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, 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. ...
0
7982
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7500
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...
0
7827
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6066
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
1961
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
0
783
bsmnconsultancy
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...

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.