Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When do you split into separate tables?
Message
From
24/10/2001 20:58:03
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
To
24/10/2001 20:43:38
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00572907
Message ID:
00572982
Views:
23
Dan,

I don't know how you get 5 tables, unless you're including things like orders and order items. Remember, the lazy man takes the hardest way.
*!* Table1 Customers
*!* Example: 1; Winegarden, Cindy, 27; NC
CREATE TABLE Customers (CustID, I, CustomerName C(x), CustomerCityID I, CustomerStateID C(2))

*!* Table2 Cities
*!* Example: 27; Durham
CREATE TABLE Cities (CityID I, CityName C(x))

*!* Table3 States
*!* Example: NC; North Carolina
CREATE TABLE States (StateID C(2), StateName C(x))

SELECT ;
    Customers.CustID, Customers.CustomerName, ;
    Cities.CityName, ;
    States.StateName ;
    FROM Customers ;
    LEFT JOIN Cities ON Customers.CityID = Cities.CityID ;
    LEFT JOIN States ON Customers.StateID = States.StateID
>Let me play Devil's advocate. Sometimes normalization leads to having city lookup tables and state lookup tables. Some like to store the Id which makes it easier to to updates. Some prefer to store the city and state directly.
>
>The problem with the IDs is that instead of a simple 3 table join, you now have a 5 table join, just to bring in the city and state names.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform