473,804 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data modelling question

Using SQL 7. I have a table with 2 fields in it that I wish to relate
to a lookup table. DDL for table 1:
CREATE TABLE [dbo].[tblPedometerRea dings] (
[ID] [varchar] (10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NOT NULL ,
[ReadingDate] [datetime] NULL ,
[PedometerReadin g] [smallint] NULL ,
[OtherActivity1] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NULL ,
[OtherActivity1M inutes] [smallint] NULL ,
[OtherActivity2] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NULL ,
[OtherActivity2M inutes] [smallint] NULL
) ON [PRIMARY]

DDL for table 2:

CREATE TABLE [dbo].[tlkpOtherActivi ties] (
[OtherActivity] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NOT NULL ,
[EquivalentSteps] [smallint] NOT NULL
) ON [PRIMARY]
In my database diagram, I want to create a 1-to-many relationship
between tblPedometerRea dings.OtherActi vity1 and
tlkpOtherActivi ties.OtherActiv ity AND between
tblPedometerRea dings.OtherActi vity2 and
tlkpOtherActivi ties.OtherActiv itiy. I get a long error message when
attempting the relationship between OtherActivity2 and OtherActivity.
Is there another schema that would work better?

Thanks.

Jul 23 '05 #1
3 2071
(ma**********@h otmail.com) writes:
Using SQL 7. I have a table with 2 fields in it that I wish to relate
to a lookup table. DDL for table 1:
CREATE TABLE [dbo].[tblPedometerRea dings] (
[ID] [varchar] (10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NOT NULL ,
[ReadingDate] [datetime] NULL ,
[PedometerReadin g] [smallint] NULL ,
[OtherActivity1] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NULL ,
[OtherActivity1M inutes] [smallint] NULL ,
[OtherActivity2] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NULL ,
[OtherActivity2M inutes] [smallint] NULL
) ON [PRIMARY]

DDL for table 2:

CREATE TABLE [dbo].[tlkpOtherActivi ties] (
[OtherActivity] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NOT NULL ,
[EquivalentSteps] [smallint] NOT NULL
) ON [PRIMARY]
Which version of SQL Server are you really using? The above scripts
does not work in SQL7 - I can tell that from the use of COLLATE
clauses.
In my database diagram, I want to create a 1-to-many relationship
between tblPedometerRea dings.OtherActi vity1 and
tlkpOtherActivi ties.OtherActiv ity AND between
tblPedometerRea dings.OtherActi vity2 and
tlkpOtherActivi ties.OtherActiv itiy. I get a long error message when
attempting the relationship between OtherActivity2 and OtherActivity.
Is there another schema that would work better?


Designwise it sounds OK (save that varchar(50) is a tad long for a
key value). If I understand you right, you get this error message
when using the diagram functionality in Enterprise Manager? I don't
use that tool, but it would somewhat easier to say anything useful,
if you could post the error message.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
Using SQL2000.

Here's the error message:

- Unable to create relationship
'FK_tblPedomete rReadings_tlkpO therActivities1 '.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Introducing
FOREIGN KEY constraint 'FK_tblPedomete rReadings_tlkpO therActivities1 '
on table 'tblPedometerRe adings' may cause cycles or multiple cascade
paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify
other FOREIGN KEY constraints.
OtherActivity can be "Biking-Hard", "Swimming-Easy", things like
that... If the customer doesn't make it clear what data will be
entered, then I leave it at varchar(50) until I get a better idea. I'm
toying with the idea of assigning an ID # to the activity and making
that the key.

Is a reflexive relationship what I need here?
Erland Sommarskog wrote:
(ma**********@h otmail.com) writes:
Using SQL 7. I have a table with 2 fields in it that I wish to relate to a lookup table. DDL for table 1:
CREATE TABLE [dbo].[tblPedometerRea dings] (
[ID] [varchar] (10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NOT NULL ,
[ReadingDate] [datetime] NULL ,
[PedometerReadin g] [smallint] NULL ,
[OtherActivity1] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL ,
[OtherActivity1M inutes] [smallint] NULL ,
[OtherActivity2] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL ,
[OtherActivity2M inutes] [smallint] NULL
) ON [PRIMARY]

DDL for table 2:

CREATE TABLE [dbo].[tlkpOtherActivi ties] (
[OtherActivity] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS
NOT NULL ,
[EquivalentSteps] [smallint] NOT NULL
) ON [PRIMARY]


Which version of SQL Server are you really using? The above scripts
does not work in SQL7 - I can tell that from the use of COLLATE
clauses.
In my database diagram, I want to create a 1-to-many relationship
between tblPedometerRea dings.OtherActi vity1 and
tlkpOtherActivi ties.OtherActiv ity AND between
tblPedometerRea dings.OtherActi vity2 and
tlkpOtherActivi ties.OtherActiv itiy. I get a long error message when attempting the relationship between OtherActivity2 and OtherActivity. Is there another schema that would work better?


Designwise it sounds OK (save that varchar(50) is a tad long for a
key value). If I understand you right, you get this error message
when using the diagram functionality in Enterprise Manager? I don't
use that tool, but it would somewhat easier to say anything useful,
if you could post the error message.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Jul 23 '05 #3
(ma**********@h otmail.com) writes:
Using SQL2000.

Here's the error message:

- Unable to create relationship
'FK_tblPedomete rReadings_tlkpO therActivities1 '.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Introducing
FOREIGN KEY constraint 'FK_tblPedomete rReadings_tlkpO therActivities1 '
on table 'tblPedometerRe adings' may cause cycles or multiple cascade
paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify
other FOREIGN KEY constraints.


You never said that you had chosen cascading delete/update for the
relationship. You will be able to define the constraint, if you select
NO ACTION. (Which means that an attempt to delete a referenced row
in tlkpOtherActivi ties will result in an error.)

While SQL 2000 supports DELETE/UPDATE ON CASCADE on foreign keys,
there are many restrictions. In some cases they are necessary, in
some cases the SQL Server developers were a bit on the conservative
side when they disallow cascading.

I don't use cascading DRI myself, so I have not dug into the details.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

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

Similar topics

0
1050
by: zeroSpaMISBaDtype | last post by:
Hi, A friend of mine at Newcastle University is looking to get in touch with someone doing numerical modelling in C++ (preferably, but not essentially, using DEAL 2. To be honest, I think he'd welcome an email from someone doing numerical modelling even without C++). If anyone is, could they contact him at s.r.ASpaMStoppinGThinGpilditch@ncl.ac.uk ? He's using GNU C++ under Cygwin with DEAL 2, and the modelling he's
1
1486
by: sandwich_eater | last post by:
Is there a relatively easy to use, not too advanced but practicle, general, not too proprietary, C++ compatible / SQL 92 (or similar standard) data dictionary / data modelling library / software and book / manual? I am looking for something more traditional than OO data storage / processing at this stage, but if it can handle inherited objects and such like without getting overly complex then I can accept that. Import, export, flexibily,...
1
4723
by: Markus Seibold | last post by:
Hi, I am looking for an open source (free) data modeling tool for PostgreSQL. It should - if possible - support: - E-R-Modelling - relational data model / modeling - (GUI SQL interface to the database) - platform independence (Win32, Mac, Unix/Linux)
1
2286
by: Stephen Chell | last post by:
Hi, I'm new to DB2 and I'll be doing some data modelling for a UDB 8.1 database. I'll need a data modelling tool that is capable of generating DDL. Does IBM provide such a tool? Is there a cost? Ideally it would support the XML datatypes used by the DB2 XML Extender (not an absolute requirement though). Thanks in advance ... Steve
17
7182
by: Sulu's Beard | last post by:
Hey gang, I'm evaluating the CA ERWin product for an upcoming data warehousing project. I'm most excited about the reverse engineering aspect of this system. I've sucessfully tested it on a SQL Server 2000 system, however, when I run it against our iSeries DB2 system (on which our ERP exists), I encounter errors that essentially say that files are missing from our SYSCAT library. I'm not an iSeries expert, but I can say that the
8
1870
by: Riegnman | last post by:
Hey guys, I'm in need of a little help. I am very new to access but have been trying to learn. My problem is as follows. . . We have time clocks that dump the badge punches into a .log file on one of the servers. I then use access to import these .log files and separate the data into various tables so that I can manipulate it. The problem is that the time clock just records punches and not "in" and "out" times. The data that comes...
8
1644
by: ml | last post by:
My employers currently use Access for processing large volumes of data for reporting and simple modelling, which involves a lot of make table/update queries etc. I have been asked to work on a retail forecasting model, but looking at the spec. the base data tables have approximately 6 million records. I know this can theoretically be done using Access (Access 97) but in reality it is extremely slow (even with the necessary tables...
1
2192
by: yaduraj | last post by:
Hello All, I have some basic questions regarding the implementation of a data bus model in a simulator. Its hard for me to realize how to model something of that sort in a simulator..suppose I need to model a 200mhz bus and contention on it..for data coming from memory. I copied fraction of code that does this..but I am not sure if it does
1
2590
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am looking for a robust solution for a major application. Almost every developer seems to come up with a completely different solution. While many of them are not bad, I really want a very good one. My database is SQL Server 2000 and I am using Visual...
5
1221
by: BigBadDom | last post by:
Hi all, A question on Data Modelling... Not strictly a php question If there is a MySQL NG out there with frequent users please point it out to me and I will re-post there... otherwise if you can help I would appreciate it greatly... ----
0
9716
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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,...
0
10354
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10359
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,...
0
10101
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6870
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();...
0
5536
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...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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 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.