473,796 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

table structure problem

Help :-) I can't see how this should be laid out!

Consider the scenario of a car rental company. They have "cars" and "lots"
(nationwide) and "customers. " So far it is easy to query each of these. A
car is rented by a customer so there would be say a "rentals" table. A car
is rented and returned over and over so there would be many rentals for each
car. One thing to remember is that the car isn't assigned to a specific lot
so either the customer has the car or it is in a lot (somewhere) and
available for rental.

So the question is how do I layout the tables (and query) to find out where
a specific car is? Or where all the cars are for that matter. I don't
think it is as simple as it looks at first glance. Clearly there can be a
column in the car table containing a LocationId but that wouldn't indicate
whether it is a LotId or a CustomerId. There could be a column for both
LotId and CustomerId and with only one filled in at a time but that doesn't
lend itself to an elegant SQL query does it?

I thought there might be a LocationIdType field. It could be set to
indicate whether the LocationId is a "lot" or a "customer" which permits me
to join with the lots or customers table but I wondered if there is another
way.

Is that enough information to go on? I can give more details if it helps.

Thanks,
Tom

Jul 20 '05
25 3391
"rkc" <rk*@yabba.dabb a.do.rochester. rr.com> wrote...
Well, I'm not as happy with the structure I outlined as you seem to be.
There are some fundamental things I would change.


If it's an improvement I'd be happy to listen. I'd prefer not to run into a
stumbling block a week from now :-)

Tom
Jul 20 '05 #21
rkc

"Tom Leylan" <ge*@iamtiredof spam.com> wrote in message
news:2J******** *************@t wister.nyc.rr.c om...
"rkc" <rk*@yabba.dabb a.do.rochester. rr.com> wrote...
Well, I'm not as happy with the structure I outlined as you seem to be.
There are some fundamental things I would change.
If it's an improvement I'd be happy to listen. I'd prefer not to run into

a stumbling block a week from now :-)


Going back to your original post where you had Cars, Lots and
Customers:

Vehicles (VehicleID*, Type, etc.)
Lots (LotID*, Address, etc.)
Customers (CustomerID*, etc.)

Learning from Mike Sherill's input:

VehicleEvents (EventID*, EventType*, VehicleID*, StartDate*, EndDate)
At this point you have one EventType - Rental.
Other possible events: Service, In Transit, Sale, etc.

VehicleLots (VehicleID, LotID, DateIn, DateOut)
Lot where vehicle is currently based

RentalDetails (EventID, VehicleID, CustomerID, etc.)
The query to answer where all vehicles currently are is basically the same
as before. What I hope this does is clear up why a CustomerID has to
be unique only in the context of the Customer table. It does not identify
where a vehicle is at the moment, just who it was rented to if it happens
to be rented at the moment.

Jul 20 '05 #22
"rkc" <rk*@yabba.dabb a.do.rochester. rr.com> wrote...
The query to answer where all vehicles currently are is basically the same
as before. What I hope this does is clear up why a CustomerID has to
be unique only in the context of the Customer table. It does not identify
where a vehicle is at the moment, just who it was rented to if it happens
to be rented at the moment.


Well I'm going to have to think the entire thing through again. I don't
quite see it as the vehicle is "based" at a lot. The lot isn't more or less
significant than the customer or any other location, it is just one place
the vehicle can be at. Then certain rules govern what transfers can be
made. From a lot it can transfer to another lot or to a customer but from a
customer it can only transfer to a lot (for instance.)

Different data needs to be kept depending upon the type of exchange...
"rental", "return", "service", "sale", "transfer" but generally speaking
these all change the location. I think "location" is a property of any
physical object (in this case the vehicle.) If we painted the car it's
color would change. If we didn't care when it happened we could just change
the color property in the vehicle record but if we did care we would need to
retain the details in another table. And I'll go out on a limb and guess
that "if it wasn't a pain" we would care enough to keep the details. The
details might be significant later when we don't have them.

As a side note (perhaps you have some insights into this) I find it
extraordinarily curious given how long relational databases, software
development, and the need to solve certain "standard" problems have been
around that there aren't more "engineered solutions" to these things. By
that I mean a solution that some majority of developers have agreed upon
"works."

These domain-related solutions are duplicated all over the place, it could
be cars, it could be video tapes, I suppose it would be the same for
tracking for prisoners in the prison system. It sure would be nice if there
was a well-structured model available.

Thanks again for all your input on the subject, I really think you went out
of your way to help.
Tom
Jul 20 '05 #23
rkc

"Tom Leylan" <ge*@iamtiredof spam.com> wrote in message
news:Oc******** *************@t wister.nyc.rr.c om...
Well I'm going to have to think the entire thing through again. I don't
quite see it as the vehicle is "based" at a lot. The lot isn't more or less significant than the customer or any other location, it is just one place
the vehicle can be at. Then certain rules govern what transfers can be
made. From a lot it can transfer to another lot or to a customer but from a customer it can only transfer to a lot (for instance.)
was a well-structured model available.


The rental lot is the 'default' location of a vehicle. If the vehicle
doesn't
have a record in the events table with a null end date then it is by default
at the corresponding lot as indicated by a record with a null dateout
field in the VehiclesLots table. The reason for the VehiclesLots table
is so that you can track the history of the locations a vehicle was rented
out from. If you don't need or want that information then stick a LotID
in the Vehicles table and update it when the vehicle is moved to a different
rental lot. That will tell you where the vehicle is being rented from now,
but you won't know for certain where it was rented from a week ago.

BTW, I have a VehicleID in the RentalDetails table that isn't necessary.
That's determined by a join to the Events table via the EventID.


Jul 20 '05 #24
"rkc" <rk*@yabba.dabb a.do.rochester. rr.com> wrote...
The rental lot is the 'default' location of a vehicle. If the vehicle
doesn't have a record in the events table with a null end date then
it is by default at the corresponding lot as indicated by a record
with a null dateout field in the VehiclesLots table.
That will prove to be a poor assumption. <grin> I have a hard time
explaining the concept to people but nothing is ever static and I try (not
always successfully) to provide room for growth. If you assume immediately
that the vehicle must be in a lot if you can't find it anywhere else you
curtail the ability to have vehicles "on order" for instance.

You already mentioned how "in transit" would be good. Then the company
could add vehicles to the vehicle table that are pending delivery. That's
immediately useful so they don't order too many of one type, don't get
overly concerned with a shortage at the moment, etc., etc. They aren't
assigned to a lot until they are delivered since which lot they will go to
may not be known until delivery.

There is absolutely nothing wrong from establishing a "lot-based' view but I
think it would be nice to track things from the vehicle's viewpoint. I
might be chasing my tail on this but I don't see why we would query the
vehicle for it's color, how many miles it has, (and if it had at GPS system)
"where are you now" but not consider querying it for whether it is in a lot
or a customer has it or anything else. We're probably saying the same thing
but in different words. I'd rather not think of it as defaulting but rather
that the record actually indicates it is at a lot just as the record is
checked to see if it is anywhere else.
The reason for the VehiclesLots table is so that you can track the history of the locations a vehicle was rented out from.
You'd never want to lose that information it's part of the invoice if
nothing else. It's a given that you need to know who, what, where, when,
and how much.
BTW, I have a VehicleID in the RentalDetails table that isn't necessary.
That's determined by a join to the Events table via the EventID.


Thanks,
Tom
Jul 20 '05 #25
On Mon, 22 Sep 2003 21:46:06 GMT, "Tom Leylan"
<ge*@iamtiredof spam.com> wrote:
Mike your time is much to valuable to spend devising semantic arguments...
I'm not devising semantic arguments. But I am talking about
semantics, because semantics are a big part of your problem.
everybody over the age of two pretty much knows that "you have it" is all
the library cares about.
You'd think that everybody over the age of two would pretty much know
that saying "you have it" isn't the same as saying "It is in
Cleveland". In relational design, different sentences are roughly
equivalent to different predicates; different predicates imply
different tables and columns.
Check the vehicle disposition table, of course.


Well that's why you're in charge of things.


Because I'd look in the vehicle disposition table for vehicle
dispositions? Who wouldn't?
I always admire how newsgroup conversations can be carried on in such an
adult manner... like your general assumption that I could be confused about
the way a library book works.


Earlier, you wrote this:

--
Hi Mike... I don't follow this, when did libraries stop tracking which
books you've borrowed? You can't think I mean "where" in terms of
latitude and longitude and in the case of a library book they don't
care which shelve (if any) you have it on. That you have it is it's
"location" right?
--

Based on that, I'd have to say you clearly don't understand the
difference between "who has it" and "where is it".

--
Mike Sherrill
Information Management Systems
Jul 20 '05 #26

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

Similar topics

0
2442
by: Randall Sell | last post by:
Hello all, I am migrating a Paradox application to SQL Server. My problem is that the existing Paradox table structure is limited. Correcting it will mean a re-write of the application (Delphi app). Although the record and column limits are higher in SQL Server, it will eventually hit the wall. So I was wondering if anyone could offer advise on how we might do this best.... The application is essentially an evaluation tool. It is very...
1
4063
by: mksql | last post by:
As an example, I am building an authentication mechanisim that will use data in the 3 left tables to determine rights to objects in a destination table, diagrammed below. In this structure, multiple records in the left tables will point to multiple records in the right table. Normally, I would approach this problem using junction tables (LeftID, RightID) to create many-to-many joins. However, given the structure of each table is nearly...
4
3260
by: Laphan | last post by:
Hi All Wonder if you could help, I have a bog standard table called STOCKPRICES that has served me well for a while, but now I need to change the structure of it and because a number of users have used it in it's present form I need to so the following in SQL script: a) Grab a snapshot of the current SQL data. b) Re-structure the STOCKPRICES table.
5
1900
by: brett valjalo | last post by:
Hey Gang! SORRY ABOUT THE LENGTH! Nice to see some of the same faces around this place from way back when ... Whatta buncha CDMA addicts some o' y'all are ;) Don't get me wrong, I understand, believe me! Took me a lot of therapy, various 12-step programmes, interventions by loved ones, etc, but I finally managed to excavate, er, extricate myself from the
4
5859
by: dough | last post by:
I have a hash table with seperate chaining with a bunch of words in it. Here is my declaration: typedef struct word *word; struct word { int count; char *s; word next; };
3
1571
by: Pavan | last post by:
Hi All, I am having a wierd problem while displaying my panel. My code is something like this <table> <tr> <td width=100>label</td> <td width=100>label</td> <td width=100>label</td> <td width=100>button in this cell</td>
0
2016
by: The Frog | last post by:
Hello Everyone, I have been asked to try and create a single SQL query to retrieve product information from a database. The way that data is arranged is that in some tables there are user defined "attributes" or "dimensions" that in turn connect to the actual product table via a many-many (using a linking table). In each linking table there is a combination of the "dimension", the productID, and the "fact" that is stored against the...
12
9140
by: Michael.Z | last post by:
Anyone who can help: Given a Table.h file I am writing a Table.c file. I keep getting the compile error: previous declaration of Table was here / conflicting types for I think the problem was the result of two pieces of code. First: typedef struct Table; /* in Table.c*/
7
3894
by: billelev | last post by:
I'm building a database and am a bit stumped about how to construct/link tables. I will describe the current configuration, then present the problem I am trying to solve. Currently: I currently have a table called tblSeries. This table holds information about a time series of data, and how that data should be displayed. It has a SeriesDataID field that will link to another table (tblSeriesData) that contains information about the name...
6
26334
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this one table. My problem is I have two buttons I want to use this code for for the two buttons would put the data in different tables. I have tried copying and changing a few things and nothing will work for me. The code is set up in a module and then I...
0
9685
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
10465
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10200
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
10021
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
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5453
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.