Click here to Skip to main content
15,923,273 members
Home / Discussions / C#
   

C#

 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 7:29
Colin Angus Mackay6-Dec-06 7:29 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 7:27
Colin Angus Mackay6-Dec-06 7:27 
AnswerRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 7:25
Colin Angus Mackay6-Dec-06 7:25 
AnswerRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 7:30
Colin Angus Mackay6-Dec-06 7:30 
GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 7:49
mfcuser6-Dec-06 7:49 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 8:01
Colin Angus Mackay6-Dec-06 8:01 
GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 8:37
mfcuser6-Dec-06 8:37 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 9:35
Colin Angus Mackay6-Dec-06 9:35 
mfcuser wrote:
What I said, you have table A inside table A you have fields A, B, C, D.


You cannot nest tables. You cannot have one table inside another table.

You can have related tables. Table A is related to Table B.


mfcuser wrote:
Now, inside field A, you have data A1, A2, A3 etc.


You mean there are a number of rows, and for each row column A will contain data such as A1, A2, A3, etc. (Please try and pick up the correct terminology - it will make things much easier).


mfcuser wrote:
Now, I want to create new tables for those fields. For example, I will have three new tables: A1, A2, A3. The way to look at it, for each value in field A, I have a new table or you can call it for each row.


This is very unwise. As I have suggested before you have 2 tables. Table A and Table B. You filter the result of table B on its foreign key (which is the link to table A).

mfcuser wrote:
This is what I really like to do, but I don't know if database allows you to do that. Can you have a table inside a table?


No, you cannot - you relate them as I've mentioned previously.

One customer can have many orders

Customer Table:
Id, FirstName,  Surname, ....
------------------------------
 3, Joe,        Bloggs, ....
 5, Sarah-Jane  Smith, ....
 
CustomerOrder Table:
Id, CustomerId, OrderDate,  DispatchDate, ....
------------------------------------------
 1, 3,          2006-12-01, 2006-12-06, ....
 2, 5,          2006-12-02, 2006-12-06, ....
 3, 3,          2006-12-06, -null-, ....


We see here that Joe Bloggs has made 2 orders.

They can be joined together like this:
SELECT FirstName, Surname, OrderDate, DispatchDate
FROM Customer
INNER JOIN CustomerOrder ON Customer.Id = CustomerOrder.CustomerId

which will return
FirstName,  Surname, OrderDate,  DispatchDate
--------------------------------------------
Joe,        Bloggs,  2006-12-01, 2006-12-06
Sarah-Jane, Smith,   2006-12-02, 2006-12-06
Joe,        Bloggs,  2006-12-06, -null-





Upcoming Scottish Developers events:
* We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker?
* Developer Day Scotland: are you interested in speaking or attending?


My: Website | Blog | Photos

GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 10:08
mfcuser6-Dec-06 10:08 
AnswerRe: Database Design Question/Problem Pin
Guffa6-Dec-06 8:02
Guffa6-Dec-06 8:02 
AnswerRe: Database Design Question/Problem Pin
User 17164926-Dec-06 8:49
professionalUser 17164926-Dec-06 8:49 
GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 9:03
mfcuser6-Dec-06 9:03 
GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 9:44
mfcuser6-Dec-06 9:44 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 10:08
Colin Angus Mackay6-Dec-06 10:08 
GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 10:26
mfcuser6-Dec-06 10:26 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 10:49
Colin Angus Mackay6-Dec-06 10:49 
GeneralRe: Database Design Question/Problem Pin
mfcuser6-Dec-06 11:02
mfcuser6-Dec-06 11:02 
GeneralRe: Database Design Question/Problem Pin
Paul Conrad6-Dec-06 11:16
professionalPaul Conrad6-Dec-06 11:16 
GeneralRe: Database Design Question/Problem Pin
Colin Angus Mackay6-Dec-06 12:03
Colin Angus Mackay6-Dec-06 12:03 
QuestionDo developers post as other users....? Pin
ednrgc6-Dec-06 7:01
ednrgc6-Dec-06 7:01 
AnswerRe: Do developers post as other users....? Pin
Colin Angus Mackay6-Dec-06 7:35
Colin Angus Mackay6-Dec-06 7:35 
AnswerRe: Do developers post as other users....? Pin
Eric Dahlvang6-Dec-06 10:08
Eric Dahlvang6-Dec-06 10:08 
Questionstore file location Pin
Kim06186-Dec-06 5:52
Kim06186-Dec-06 5:52 
AnswerRe: store file location Pin
ednrgc6-Dec-06 6:52
ednrgc6-Dec-06 6:52 
AnswerRe: store file location Pin
Ravi Bhavnani6-Dec-06 7:33
professionalRavi Bhavnani6-Dec-06 7:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.