
Originally Posted by
lawrencee99
It only just occurred to me that their might be multiple instances of a particular fruit on the list. . . Do you think it will be possible to tag them with alphanumeric strings, so that rather than have their names typed into the search bars, I can simply use the alphanumeric string to bring out details of the "particular" apple attached to it.
Depends on how you need to use it. If you simply need to know that two given apples are different (and be able to manipulate their records reliably), then you can simply let MySQL generate a serial id for them. If you need to be able to "look up" specific apples, then you need to decide on some sort of id format that your application can predict. (I think the former will probably be the better solution, in this case.)

Originally Posted by
lawrencee99
I am trying to do this using the cPanel->MySQL Databases.
That really doesn't tell me anything. cPanel doesn't administer MySQL; it uses other software to do it. There might even be several to choose from (phpMyAdmin is one of the most common).

Originally Posted by
lawrencee99
Yes the locations and destinations would be predefined.
Alright. Those items that are "predefined" -the types of fruit and locations, for now- get their own tables. You would have another table for your "tracking" records, which references those tables for fruit names and locations. For example:
Code:
create table `fruit`(
name varchar(50) primary key
)engine=innodb;
create table `location`(
`id` serial primary key,
`address` varchar(50) not null,
-- city, state, etc.
)engine=innodb;
create table `fruit_tracking`(
`id` serial primary key, -- an auto-generated id number
`fruit` varchar(50) not null, -- the fruit.name of the fruit we are tracking
`origin` bigint unsigned not null, -- the origin's location.id
`destination` bigint unsigned not null, -- the destination's location.id
`dispatched` datetime not null,
`eta` datetime not null,
-- a "foreign key" is a reference to the info in a record in another table.
-- this allows the DB to make sure the kind of fruit, locations, etc., actually exist before using them.
foreign key(`fruit`) references `fruit`(`name`),
foreign key(`origin`) references `location`(`id`),
foreign key(`destination`) references `location`(`id`)
)engine=innodb;
Let me know if you understand all that. I'm going to bed now; we can look at how to query your records next.
Bookmarks