Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
When do you split into separate tables?
Message
De
24/10/2001 20:58:03
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
24/10/2001 20:43:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00572907
Message ID:
00572982
Vues:
24
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform