-1

First off all I'm using SQL Server CE and I've created a data context for my database to handle it in C# code.

This is my problem:

In TableA, there are several "static" items that won't change: they are "attributes" like the following:

Name=available 24 hours, ID=1, isset=1

where Name is a string, ID type of int and isset a bit.

There are about 100 attributes in the list.

Now, I have TableB with items that can have these attributes. I can't add a relation between a Column AttributeID and the attributeID, because the item can have several.

But I can't add a column with the itemID in the attributes table either, because several items can have this attribute.

So what can I do? Is there a way in SQL Server CE to achieve this?

EDIT: So, I'll try to explain more clearly:

My TableA is a table with 3 columns: Name, ID and isset. Each row in this TableA represents one item, let's call it itemA. There are about 100 rows (= 100 itemA) in the table.

Now, my TableB represents itemB that can have one or several of these itemA.

But I don't know how to do this: It wouldn't work to add a relation between a column of TableB called itemA_ID and the column of TableA called ID, because one itemB can contain more than one itemA. But the opposite way round, it wouldn't work either: A relation between a column itemB_ID of TableA and a column of TableB called ID is neither possible, because one itemA can refer to more than one itemB.

I know it's a bit complicated but I hope that it's a bit easier to understand now.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Your question is hard to understand. Can you give us more than a single example of what you mean? Also, avoid vague terms like "Name", "Attribute", "Item", and so on. Use names of the actual data you will be storing. – Dour High Arch May 06 '13 at 18:39
  • SQL Server Compact is a RDBMS, and if no RDBMS features fit the bill, then no - maybe you are modelling your data in a wrong way... – ErikEJ May 06 '13 at 19:24

1 Answers1

0

Your question is hard to understand, but I am guessing you have a one-to-many relation. That is, you have many "Item"s, each of which can have many "attributes".

The way to handle this is to create a lookup table for each relation. E.g.:

TableA
AttributeID  Availability
          1  Available 24 hours
          2  Available 48 hours

TableB
ItemID  IsSet  ItemName
     1      1  Something

TableC
ItemID  AttributeID
     1            1
     1            2

If that is not what you mean, please provide examples of your data.

Dour High Arch
  • 21,513
  • 29
  • 75
  • 90