Link to home
Start Free TrialLog in
Avatar of PeteEngineer
PeteEngineerFlag for India

asked on

Design Question!


I have two tables:

LLocation (LenderId RegionId StateId CityTypeId)

LCity (LenderId CityId)

Each lender will be there in different regions,
inside region there will be state,
inside state there will be citytypes,
inside citytype there wil be cities
one lender will have only one city

RegionId,StateId,CityTypeId will be inserted the value null.
if all region or all state or all citytype selected

I need a sql query which to

insert and update into these two tables

and a query to

search based on LenderId RegionId StateId CityTypeId
where  Lenderid RegionId CityTypeId  are dropdown
and StateId  will have a text box value


Note: If the Null in a column , means all so just i need to show one
      row have null "all" not the sub values that comes under "all"
 
Avatar of HainKurt
HainKurt
Flag of Canada image

insert into LLocation (LenderId) values(@LenderID);

update LLocation set
  RegionId =@RegionId
  StateId =@StateId
  CityTypeId=@CityTypeId
where LenderId=@LenderID);
Wow..I don't know where to begin.  Please, please take a deep breath, slow down, and get some assistance with your table design, your understanding of nulls, and better express your requirements.  You are not ready to formulate queries.

Just to illustrate a couple "issues" that pop out:
1. Each lender can be in different regions, thus different states. thus different cities. But, one lender will have only one city??????

2. "Inside state there will be city types".  Are you sure?  I can only guess what a city type is, but NONE of my guesses would have city type within state.  Are you saying two states cannot have the same city type?  Or or you just describing one way of drilling down to a city of interest?  

3.  You do not have data that shows which state a city is in or which city-type describes a city.



 
   
Avatar of PeteEngineer

ASKER

one lender will have only one city?????? yes
 "Inside state there will be city types".  Are you sure? no
Are you saying two states cannot have the same city type? Yes



ASKER CERTIFIED SOLUTION
Avatar of dqmq
dqmq
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial