Discussion
With little prior experience, how easy would it be to create a database with the following specification:
Inputs as a list. For example:
Item 1
Item 2
Item 3
Item ...
Item n
Then sorted/queried to show which items come before/after each individual item.
A basic example:
John has Cereal, Toast and Tea for breakfast.
James has Toast, Milk and Banana for breakfast.
Jack has Tea, Porage and Yoghurt for breakfast.
I would like to put these into a database as [item 1], [item 2] and [item 3] the ask the database "What did anyone have after eating toast" with the answer being " 1 Tea, 1 Milk".
Inputs as a list. For example:
Item 1
Item 2
Item 3
Item ...
Item n
Then sorted/queried to show which items come before/after each individual item.
A basic example:
John has Cereal, Toast and Tea for breakfast.
James has Toast, Milk and Banana for breakfast.
Jack has Tea, Porage and Yoghurt for breakfast.
I would like to put these into a database as [item 1], [item 2] and [item 3] the ask the database "What did anyone have after eating toast" with the answer being " 1 Tea, 1 Milk".
creating tables, inserting data and returning data in order will be found very early in any good introduction book/tutorial on SQL database. Using tools like MySql Workbench (assuming you are using MySql ) can make them trivial exercises
Understanding what tables and columns the database should contain - is harder (3 tables wouldn't be unreasonable for problem - one for the people, one for food items and one to link the person to the items consumed at meal, though maybe overkill for trivial example)
"What did anyone have after eating toast" - I suspect a lot of programmers would resort to doing in code, though it is possible to construct queries to do it (but likely database dependant)
Understanding what tables and columns the database should contain - is harder (3 tables wouldn't be unreasonable for problem - one for the people, one for food items and one to link the person to the items consumed at meal, though maybe overkill for trivial example)
"What did anyone have after eating toast" - I suspect a lot of programmers would resort to doing in code, though it is possible to construct queries to do it (but likely database dependant)
I think everyone is over thinking here 
First of all, do you really need a database OP? Tell us more about your requirements - more importantly the scale of it.
If you want an analysis of what people have for breakfast (as an example) you could start with Excel.
Assuming breakfast consists of 3 courses
Column 1 = Name
Column 2 = First item
Column 3 = Second item
Column 4 = Third item
You can create lookup table in Excel (rule validation) so you get nice dropdown in columns 2-4
If you really need a database I'd suggest MS Access. Really easy to start.

First of all, do you really need a database OP? Tell us more about your requirements - more importantly the scale of it.
If you want an analysis of what people have for breakfast (as an example) you could start with Excel.
Assuming breakfast consists of 3 courses
Column 1 = Name
Column 2 = First item
Column 3 = Second item
Column 4 = Third item
You can create lookup table in Excel (rule validation) so you get nice dropdown in columns 2-4
If you really need a database I'd suggest MS Access. Really easy to start.
stevenjhepburn said:
davepoth said:
Being lazy, I would probably do it using the SUMIFS function in Excel.
Would that work with the items being in different columns? In the breakfast example John's toast might be in column C whilst James' toast would be in column B.=IF(B2="Toast",C2,IF(C2="Toast",D2,IF(D2="Toast","Toast was the last thing this person had","")))
Then COUNTIF the results in column E.
crazy about cars said:
First of all, do you really need a database OP? Tell us more about your requirements - more importantly the scale of it.
For the idea I have it really has to scale big, quickly.crazy about cars said:
If you want an analysis of what people have for breakfast (as an example) you could start with Excel.
Assuming breakfast consists of 3 courses
Column 1 = Name
Column 2 = First item
Column 3 = Second item
Column 4 = Third item
You can create lookup table in Excel (rule validation) so you get nice dropdown in columns 2-4
I was a little too uniform in my initial example. For what I'm thinking, the breakfast example equivalent would be some people having 2 items and some people having 10+ items.Assuming breakfast consists of 3 courses
Column 1 = Name
Column 2 = First item
Column 3 = Second item
Column 4 = Third item
You can create lookup table in Excel (rule validation) so you get nice dropdown in columns 2-4
Not really difficult if order is required
2 tables, 1 for people, 1 for items
People table - I don't know what info needs storing but say first name, last name, phone number with userid as primary key.
Items table - again, personid, item name and position (I.E. 1 is first, 2 is second etc)
Should be fairly simple with a nice little SQL statement and could handle 2 courses or 2,000,000 courses (mmmmm breakfast with lots of courses!!)
2 tables, 1 for people, 1 for items
People table - I don't know what info needs storing but say first name, last name, phone number with userid as primary key.
Items table - again, personid, item name and position (I.E. 1 is first, 2 is second etc)
Should be fairly simple with a nice little SQL statement and could handle 2 courses or 2,000,000 courses (mmmmm breakfast with lots of courses!!)
stevenjhepburn said:
I was a little too uniform in my initial example. For what I'm thinking, the breakfast example equivalent would be some people having 2 items and some people having 10+ items.
Not a major problem if coding. Off the top of my head, in a pseudo-Excel VBA style:
For Each person In database
MaxItems = Count(HowManyItems)
For NoOfItems = 1 to MaxItems
If Item(NoOfItems) = "Toast" Then
WhatTheyHadAfterToast = Item(NoOfItems + 1)
End If
Next NoOfItems
Next person
'WhatTheyHadAfterToast' would represent an array, an Excel worksheet or a temporary table - whatever would be suitable to store multiple values, then do the COUNTIF or whatever you need to do with it.
davepoth said:
Is the order in which people are eating critical? That makes it a bit tricky.
Just what I was thinking after reading the OP.stevenjhepburn said:
<snip>
I would like to put these into a database as [item 1], [item 2] and [item 3] the ask the database "What did anyone have after eating toast" with the answer being " 1 Tea, 1 Milk".
Which I think would mean that you would not only have to record what was eaten, but at what time, or in what sequence.I would like to put these into a database as [item 1], [item 2] and [item 3] the ask the database "What did anyone have after eating toast" with the answer being " 1 Tea, 1 Milk".
TonyRPH said:
Which I think would mean that you would not only have to record what was eaten, but at what time, or in what sequence.
That's not particularly tricky though, either use an auto-increment id (which can't be guaranteed, but I've never seen it fail) or just a timestamp on the what was eaten field?stevenjhepburn said:
crazy about cars said:
First of all, do you really need a database OP? Tell us more about your requirements - more importantly the scale of it.
For the idea I have it really has to scale big, quickly.If you can give more information on the scale and characteristics that you are looking for, you will get better recommendations.
stevenjhepburn said:
I was a little too uniform in my initial example. For what I'm thinking, the breakfast example equivalent would be some people having 2 items and some people having 10+ items.
Still doable but more into database realm (or advanced Excel depending how how you capture the data).Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


