Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Wednesday, March 28, 2012

Property Database Design Issue

Hi !!

I need some inputs for designing Property Database

Property Types:

Condo/Townhouse

Single Family Home

Multi Family Home

Rental

Property Features

Sq Ft

# Of floors

New Construction

Carpeted Floors

Hardwood Floors

Living Room

Formal Dining Room

# of Bedrooms

# of Bathrooms

Den/Office

Water : City or Private

Sewer: City or Septic

Family Roomand more

Lot Features

Mountain View

Golf Course Lot

Golf Course Viewand More

Community Features

Boating

Golf

Gym

Swimmingand More

Here is what I am thinking:

1) I probably don't need any table for Property Type as I can hard code them into Drop Down List

2) Water and Sewer feature can de coded into Drop Down List too

3) How rest of the table design should work?

Table called Property, Lot Feature, Community Feature, Property_Lot, Property_Community

Property Table has PropertyID (P1, P2, P3) and other Info

Lot Feature has Lot Feature ID (L1, L2, L3) and

Community Feature has (C1, C2, C3)

Property can have zero or More Lot Feature

soProperty_Lot table will have:

P1, L1

P1, L2

P1, L3

P2, L3

P3, L1

Property can have zero or more Community Feature, soProperty_Community

P1, C1

P2, C1

P2, C2

P3, C3

Is this right?

How do we design search query?

I think query will be dynamic query? correct?

Thanks !!!!

1) If you making them a radio button, ok. If you are putting it into a dropdown, I'd make a table entry.

2) See #1.

3) Looks pretty good, but when you say P1,P2,L1,L2, just make the ID's an autoincrementing identity, not 'P1' perse, but an identity of 1,2,3,etc. I'll assume that is what you meant.

Yes, that is right.

Seach for what?

I wouldn't use a dynamic query, no.

|||

Looked into your suggestions.

Search for:

Give me a list of property where Property Has feature L1 AND L2 and C1

or

Give me a list of property where Property has feature L1

Now, this type of query will need a join with other tables and parameters are completely unknown, # of parameters selected and passed to query are unknown till runtime. In this case what is the alternative for dynamic query?

--------------------

We also thought about something like this:

1) Property Table

2)Property_Lot table. This table looks like this:

0 = No

1 = Yes

Columns are:

PropertyID, MountainView, Golf View, Cornor Lot, River front Lot (and about 10 more)

Data:

P1, 0, 0, 1, 1

P2, 1, 1, 1, 0

This means Property P1 is Cornor Lot and River front

P2 is Mountain View, Golf View, Cornor Lot

Now, the problem is how to perform query on this? We might have to pass all parameter in particular order?

---- OR -----

Should I create column in Property Table "Lot Info", "Community Info"

and save comma seperated value in that column

PropertyID Lot Features Community Features

P1 L1, L2, L3 C1, C3

P2 L3 C2, C3

and now use SQL Server Full Text Search when some one says "Give me a list on Properties with Lot Feature L3 and Community Feature C3"

or "Give me a list of Properties with Lot Feature L1"

Any suggestion?

|||

You first design is best (The one in the original message).

Yes, you would do a join. Sorry, you are probably best just doing a dynamic query. You can do a static one, but it'd be extremely large, and probably pretty inefficient.

A simple dynamic query using your original design would be like:

SELECT *
FROM Properties p
JOIN PropertyLot pl ON (p.PropertyId=pl.PropertyId AND pl.LotFeatureID={Feature 1})
JOIN PropertyLot pl2 ON (p.PropertyId=pl2.PropertyId AND pl2.LotFeatureID={Feature 2})

That is assuming that you have the feature id's already, if you don't then you can do this:

SELECT *
FROM Properties p
JOIN PropertyLot pl ON (p.PropertyId=pl.PropertyId)
JOIN LotFeatures lf1 ON (pl.LotFeatureID=lf1.LotFeatureID AND lf1.Description={Feature 1})
JOIN PropertyLot pl2 ON (p.PropertyId=pl2.PropertyId)
JOIN LotFeatures lf2 ON (pl.LotFeatureID=lf2.LotFeatureID AND lf2.Description={Feature 2})

etc.

You can do a static one like this:

SELECT *
FROM Properties p
WHERE (SELECT COUNT(*) FROM PropertyLot pl JOIN Split(@.LotFeatures) s ON (pl.LotFeatureID=s.ID AND p.id=pl.id))=ValueCount(@.LotFeatures)

That assumes that you have a comma-delimited list of LotFeatureID's in @.LotFeatures, and that you have already written a Split function that takes a comma-delimited varchar field and returns a table with a single column named ID that has each value in a new row. ValueCount is a function (You have to write it) that accepts a comma-delimited varchar and returns the number of values in it. I assume that a null varchar is 0, and an empty string is 0 for count, and both return no rows from split.

|||How about using Full Text Search on 2nd approach i.e. Comma Seperated list for LotFeatures and CommunityFeatures?

Friday, March 23, 2012

proper db design methodology for "custom data"?

I am building an application that requires "custom" data elements for
various different clients of the application. For example, consider an
application that comes with a "standard" order form, that perhaphs consists
of 10 fields that we know ahead of time, orderID, Product Name, Product ID,
etc.
Now consider that the application is delivered via an ASP model, and that
clients we sell the software to, wish to customize the order form to thier
personal liking. In this scenario, they may want to only use say 7 of the
standard fields, but they have 7 additional fields that are specific to
themselves. They may have an internal ID field, or pricing fields that are
specific to themselves.
Every client who subscribes needs to be able to customize the order "form"
accordingly. so if our application is used by 100 clients, we would have
potentially 100 versions of the order form, with totally custom questions.
Of course, I don't think we would want to create 100 versions of the table.
that would be a maintenance nightmare, and be very difficult to program
against.
There is another technique which would use a LOT of meta-data to allow the
dynamic capture of the order data via the form, but this doesn't work at all
when it comes time to report on that data.
My question is, does anyone have previous experience in modeling a database
to deal eligently with these types of requirements? I would greatly
appreciate anyones experience with similiar situations and hear what has and
has not worked.
thanks!Hi Mike
Thank you for using the newsgroup and it is my pleasure to help you with
you issue.
From you information provided, you have standard fields ( all the customer
are same) and custom fields. To design the database to save all the
information, could you decribe more clear of what the customer fields might
be?
What I mean is, what is the flexibility level of the customer fields: Could
the customer specify the number of the custom fields? Is the customer could
specified a certain range of fileds with fixed datatype or as many fields
and data type as they want?
If they could just have certain custom fields and known datatype, you could
just have one table with standard fields and all the possible fields. If
the customer choose to enter the data in his specific fileds, the data will
be saved in corresponding fields; If not, the columns will be NULL.
Looking forward for you reply.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.|||Hi Baisong, thanks for your reply.
Let me take a step back and give you the bigger picture. I was using the
Orders table as an example of what we do, however, what we currently offer
is the ability for our clients to define ANY "Form", define all the fields,
what types of fields they are, and also what the input type would be
(dropdownlist, checkbox, radiobutton, etc).
Currently, we are using a strict meta-data format for capturing all the
information necessary to create the "Form" which is generated as a web page.
We have a "formtypes" table that defines a formtypeID, and then a related
"questions" table that holds the specific questions and the definition of
those questions associated with a specific FormType. The question could be
defined as numeric, or date, or text, etc. When a "Form" is submitted, it is
writes one record to a "forms" table that is an instance of that form, which
generates a formid, and then we write each response to a "responses" table,
with the corresoponding formid, and questionid. So every single response
from every single form is actually written to this one table. This has
become much too complex, and a HUGE problem is the inability to be able to
report on this data...since it's entirely custom and we don't know what they
are actually capturing.
We are attempting to look at all the formtypes and questions and create a
Taxonomy ...basically pull out "standard" data that all the clients are
asking and put that data into "real" tables. That will be piece of work.
however, we still need to allow clients to add custom fields on top of what
we offer as standard. The goal is if we can map the data they want to
capture into real fields, we will be able to much easier search on that
data, and also easily report on it. The above data model does well for
capturing purely custom data, however I was hoping for a better format that
would allow us to simplify the capture of this data, and also allow
searching and potentially reporting.
We are redoing are data schema, which is why I'm revisiting this question
and seeing if others have had to deal with this level of complexity. One
potential solution I was thinking about was using the new "Yukon" XML field
type to hold an instance of a submitted form. The form could be serialized
into XML, and could have totally different schemas and still be stored in a
single field. Based on what I read, that data can then be indexed, and
actually searched in combination with relations queries. In addition, I read
something about "promotion", which can let you "promote" specific nodes to
be written into a relational field...which could be a solution for allowing
us to have a mechanism to report on key pieces of data.
We are at the early stages of this work, so all options are open to us. Hope
this gives you a better feel for the complexity of what we are trying to
solve, and I look forward to any suggestions or ideas on the "best
practices" for dealing with this specific type of data modeling problem.
Thanks,
Mike
"Baisong Wei[MSFT]" <v-baiwei@.online.microsoft.com> wrote in message
news:FWwU1cj6DHA.2768@.cpmsftngxa07.phx.gbl...
> Hi Mike
> Thank you for using the newsgroup and it is my pleasure to help you with
> you issue.
> From you information provided, you have standard fields ( all the customer
> are same) and custom fields. To design the database to save all the
> information, could you decribe more clear of what the customer fields
might
> be?
> What I mean is, what is the flexibility level of the customer fields:
Could
> the customer specify the number of the custom fields? Is the customer
could
> specified a certain range of fileds with fixed datatype or as many fields
> and data type as they want?
> If they could just have certain custom fields and known datatype, you
could
> just have one table with standard fields and all the possible fields. If
> the customer choose to enter the data in his specific fileds, the data
will
> be saved in corresponding fields; If not, the columns will be NULL.
> Looking forward for you reply.
> Best regards
> Baisong Wei
> Microsoft Online Support
> ----
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
> Please reply to newsgroups only. Thanks.
>|||Hi Mike
Thank you for using the newsgroup and it is my pleasure to help you with
you issue.
As for saving various types of data in one table, based on my knowledge, it
is hard to do it for the data in SQL Server 2000 database needs regular
storage format. Also, to create one table for one customer would not
practical for the maintenance and developing work would be HUGE. XML would
be a choice, you could use XQuery/XPath expressions on the XML Datatype to
extract and search data and also to get data into a computed column that
can serve as a way to promote information from the XML Datatype instance
into the relational context. Actually, you could ask this question in the
newsgroup in the related newsgroup and our corresponding engineers there
would answer your question about it. The newsgroup would be:
http://support.microsoft.com/newsgroups/default.aspx?ICP=GSS3&NewsGroup=micr
osoft.public.sqlserver.xml
or
news:microsoft.public.sqlserver.xml
Thanks for your post.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.

proper db design methodology for "custom data"?

I am building an application that requires "custom" data elements for
various different clients of the application. For example, consider an
application that comes with a "standard" order form, that perhaphs consists
of 10 fields that we know ahead of time, orderID, Product Name, Product ID,
etc.
Now consider that the application is delivered via an ASP model, and that
clients we sell the software to, wish to customize the order form to thier
personal liking. In this scenario, they may want to only use say 7 of the
standard fields, but they have 7 additional fields that are specific to
themselves. They may have an internal ID field, or pricing fields that are
specific to themselves.
Every client who subscribes needs to be able to customize the order "form"
accordingly. so if our application is used by 100 clients, we would have
potentially 100 versions of the order form, with totally custom questions.
Of course, I don't think we would want to create 100 versions of the table.
that would be a maintenance nightmare, and be very difficult to program
against.
There is another technique which would use a LOT of meta-data to allow the
dynamic capture of the order data via the form, but this doesn't work at all
when it comes time to report on that data.
My question is, does anyone have previous experience in modeling a database
to deal eligently with these types of requirements? I would greatly
appreciate anyones experience with similiar situations and hear what has and
has not worked.
thanks!Hi Mike
Thank you for using the newsgroup and it is my pleasure to help you with
you issue.
From you information provided, you have standard fields ( all the customer
are same) and custom fields. To design the database to save all the
information, could you decribe more clear of what the customer fields might
be?
What I mean is, what is the flexibility level of the customer fields: Could
the customer specify the number of the custom fields? Is the customer could
specified a certain range of fileds with fixed datatype or as many fields
and data type as they want?
If they could just have certain custom fields and known datatype, you could
just have one table with standard fields and all the possible fields. If
the customer choose to enter the data in his specific fileds, the data will
be saved in corresponding fields; If not, the columns will be NULL.
Looking forward for you reply.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.|||Hi Baisong, thanks for your reply.
Let me take a step back and give you the bigger picture. I was using the
Orders table as an example of what we do, however, what we currently offer
is the ability for our clients to define ANY "Form", define all the fields,
what types of fields they are, and also what the input type would be
(dropdownlist, checkbox, radiobutton, etc).
Currently, we are using a strict meta-data format for capturing all the
information necessary to create the "Form" which is generated as a web page.
We have a "formtypes" table that defines a formtypeID, and then a related
"questions" table that holds the specific questions and the definition of
those questions associated with a specific FormType. The question could be
defined as numeric, or date, or text, etc. When a "Form" is submitted, it is
writes one record to a "forms" table that is an instance of that form, which
generates a formid, and then we write each response to a "responses" table,
with the corresoponding formid, and questionid. So every single response
from every single form is actually written to this one table. This has
become much too complex, and a HUGE problem is the inability to be able to
report on this data...since it's entirely custom and we don't know what they
are actually capturing.
We are attempting to look at all the formtypes and questions and create a
Taxonomy ...basically pull out "standard" data that all the clients are
asking and put that data into "real" tables. That will be piece of work.
however, we still need to allow clients to add custom fields on top of what
we offer as standard. The goal is if we can map the data they want to
capture into real fields, we will be able to much easier search on that
data, and also easily report on it. The above data model does well for
capturing purely custom data, however I was hoping for a better format that
would allow us to simplify the capture of this data, and also allow
searching and potentially reporting.
We are redoing are data schema, which is why I'm revisiting this question
and seeing if others have had to deal with this level of complexity. One
potential solution I was thinking about was using the new "Yukon" XML field
type to hold an instance of a submitted form. The form could be serialized
into XML, and could have totally different schemas and still be stored in a
single field. Based on what I read, that data can then be indexed, and
actually searched in combination with relations queries. In addition, I read
something about "promotion", which can let you "promote" specific nodes to
be written into a relational field...which could be a solution for allowing
us to have a mechanism to report on key pieces of data.
We are at the early stages of this work, so all options are open to us. Hope
this gives you a better feel for the complexity of what we are trying to
solve, and I look forward to any suggestions or ideas on the "best
practices" for dealing with this specific type of data modeling problem.
Thanks,
Mike
"Baisong Wei[MSFT]" <v-baiwei@.online.microsoft.com> wrote in message
news:FWwU1cj6DHA.2768@.cpmsftngxa07.phx.gbl...
quote:

> Hi Mike
> Thank you for using the newsgroup and it is my pleasure to help you with
> you issue.
> From you information provided, you have standard fields ( all the customer
> are same) and custom fields. To design the database to save all the
> information, could you decribe more clear of what the customer fields

might
quote:

> be?
> What I mean is, what is the flexibility level of the customer fields:

Could
quote:

> the customer specify the number of the custom fields? Is the customer

could
quote:

> specified a certain range of fileds with fixed datatype or as many fields
> and data type as they want?
> If they could just have certain custom fields and known datatype, you

could
quote:

> just have one table with standard fields and all the possible fields. If
> the customer choose to enter the data in his specific fileds, the data

will
quote:

> be saved in corresponding fields; If not, the columns will be NULL.
> Looking forward for you reply.
> Best regards
> Baisong Wei
> Microsoft Online Support
> ----
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
> Please reply to newsgroups only. Thanks.
>
|||Hi Mike
Thank you for using the newsgroup and it is my pleasure to help you with
you issue.
As for saving various types of data in one table, based on my knowledge, it
is hard to do it for the data in SQL Server 2000 database needs regular
storage format. Also, to create one table for one customer would not
practical for the maintenance and developing work would be HUGE. XML would
be a choice, you could use XQuery/XPath expressions on the XML Datatype to
extract and search data and also to get data into a computed column that
can serve as a way to promote information from the XML Datatype instance
into the relational context. Actually, you could ask this question in the
newsgroup in the related newsgroup and our corresponding engineers there
would answer your question about it. The newsgroup would be:
http://support.microsoft.com/newsgr...&NewsGroup=micr
osoft.public.sqlserver.xml
or
news:microsoft.public.sqlserver.xml
Thanks for your post.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.