I am building a real estate website. I have a table for properties (i.e. "houses"), a table for pictures, a table for features, etc. So each property's data comes from three, not only one table.
I need to provide a function that retrieves requested property data depending on a search criteria, for example:
property of the week
featured properties
properties on offer
the simple search
I have multiple drop-down lists for selecting country, region, area, bedrooms, price range, type, etc.
I already built many functions each dealing with one of the above cases, but I was wondering, if there was any other way of building one flexible mechanism that will retrieves whatever you want in a smart way, I mean one function that works for all cases?
I know my question is kind of vague and too broad, but bear with me please.
Thanks in advance.
PS: I am using ASP.NET 3.5, VB.NET, Visual Web Developer 2008 Express, SQL Server 2005 Express
I think you're looking to build an Advanced Search functionality that integrates with the default/simple search provided.
Why not build a single stored procedure to encapsulate all possible types of searches by specifying default values of parameters that are not passed.
In this manner, the simple search would be using all parameter defaults. Whenever any criteria is provided to narrow the search, the passed parameter value will be used by the Stored Procedure.
Is Lucene an option? Lucene.net is a great way to provide a quick and flexible search engine to your site.
When you use Lucene you also many other advantages, like fuzzy search etc...
http://www.codeproject.com/KB/library/IntroducingLucene.aspx
The question is twofold:
Can you logically unite the search for "properties of the week" and the search for "properties in this specific region, costing 100,000 or less" into a single database search?
Does it buy you anything to think of/create something that does 1.)? (Especially when you already have something that works.)
If you would answer both questions with "Yes", then I'd say you must extend the simple search. I suppose you already have a flag for each of your special cases ("property of the week", "property on offer", etc). Just add support for these flags to your simple search function.
Provide reasonable defaults for the search criteria and you can use simple search for all the cases you described.
Related
What would be the HTML code to "filter out" a handful of specific user stories?
Your question is highly unspecific. The only way to get stories is to programatically access the API via a language like Javascript, Java, C#, C++, etc., etc.
You can embed javascript into your html page and get the code to fetch stories with a filter passed in on the access. To see how to structure a query, you could turn on the developer tools in your browser and have a look at the network accesses that the browser does when fetching stories into a custom list app on a page. Using the custom list, you could refine your query to what you want first.
You could always build a custom app for a specific use case, but if you're looking for data and having trouble finding it, there are ways to do so with a combination of custom lists, Rally's own query language, and creative use of advanced filters. It's also possible to massage your data in way that makes Rally's native reporting a bit easier to use.
This is just an example but, if I'm looking to get information on the quarterly progress of my team who don't use start/end date or releases/milestones, there's not a lot available from an app/report standpoint that's already built. However, if I coach my team on keeping a few simple data elements neat and tidy, and utilize the custom report views to make that data useful, it can be pretty quick and easy to implement.
I have my teams keep a few basic fields up to date: Title, Owner, Project, Tags, Refined Estimate (all at a feature level), and most importantly - keeping a parent/child relationship between most work.
Now I can build a report that filters by a certain tag, that can also be filtered by team, and also has the ability to show additional valuable data that can be unearthed because your house is tidy. In this case, you can now display a column that will total all child objects under a certain feature, and display that next to 'Planned' estimate, which will give you the ability to also export and show a planned vs. actual to help your teams estimate more accurately.
It's a round-about way of saying there are a lot of possibilities with the tool if you can use your resources. Building custom apps means you also have to maintain them or pay someone with the knowledge to do so.
I'm using asp.net and I need to build an application where we can easily create forms without recreating the database, and preferably without changing the create/read/update/delete queries. The goal is to allow customers to create their own forms with dropdowns, textboxes, checkboxes, even many-to-one relationship to another simple form (that's stretching it). The user does not have to be able to create the forms themselves, but I don't want to be adding tables, fields, queries, web page, etc. each time a new form is requested/modified.
2 questions:
1) How do I structure a flexible database to do this (in SQL Server)? I can think of two ways: a) Create a table for each datatype (int, varchar(x), smalldatetime, bit, etc). This would be very difficult to create the adequate queries. b) Create the form table with lots of extra fields and various datatypes in case the user needs 5 integers or 5 date fields. This seems the easiest, but is probably pretty inefficient use of space.
2) How do I build the forms? I thought about creating an xml sheet that had the validations, data type, control to display, etc. as a list. Then I would parse through the xml to build the form on the fly. Probably using css to do the layout (that would have to be manual, which is ok).
Is there a better/best way? Is there something out there that I could look at to get ideas? Any help is much appreciated.
This sounds like a potential candidate for an InfoPath solution. At first blush, it will do most/all of what you are asking.
This article gives a brief overview of creating an InfoPath form that is based on a SQL data source.
http://office.microsoft.com/en-us/infopath-help/design-a-form-template-based-on-a-microsoft-sql-server-database-HP010086639.aspx
I have built a completely custom solution like you are describing, and if I ever did it again I would probably opt for either 1) a third-party product or 2) less functionality. You can spend 90% of your time working on 10% of the feature set.
EDIT: reread your questions and here is additional feedback.
1 - Flexible data structure: A couple things to keep in mind are performance and the ability to write reports against the data. The more generic the data structure, the harder these will be to achieve (again, speaking from experience).
Somewhat contrary to both performance and report-readiness, Microsoft SharePoint uses XML fragments/documents in generic tables for maximum flexibility. I can't argue with the features of SharePoint, so this does get the job done and greatly simplifies the data structure. XML will perform well when done correctly, but most people will find it more difficult to write queries against XML. Even though XML is a "first class citizen" to SQL Server, it may or may not perform as well as an optimized table structure.
2 - Forms: I have implemented custom forms using XML transformed by XSLT. XML is often a good choice for storing form structure; XSLT is a monster unto itself, but it is very powerful. For what it's worth, InfoPath stores its form structure as XML.
I've also implemented dynamic forms using custom controls in .Net. This is a very object-oriented approach, but (depending on the complexity of the UI) can require a significant amount of code.
Lastly (again using SharePoint as an example), Microsoft implemented horrendously complicated XML list/form definitions in SharePoint 2007. The complexity defeats many of the benefits. In other words, if you go the XML route, make your structures clean and simple or you will have a maintenance nightmare on your hands.
EDIT #2: In reference to Scott's question below, here's a high-level data structure that will avoid duplicated data and doesn't rely on XML for the majority of the form definition.
Caveat: I just put this design together in SQL Management Studio...I only spent 10 minutes on it; developing a flexible form system is not a trivial task, so this is an over-simplification. It does not address the storage of user-entered data, just the definition of the form.
The tables:
Form - top-level form table which contains (as you would guess) the collection of fields that comprise the form.
Field - generic fields that could be reused across forms. For example, you don't want 50 different "Last Name" fields for 50 different forms. Note the "DataTypeId" column. You could store any type you wanted in this column, like "number, "free text", even a value that indicates the user should pick from a list.
FormField - allows a form to contain 0-many fields in its definition. You could even extend this table to indicate that the user can ADD as many of this field as they need.
Constraint - basically a lookup table that defines a constraint type (maybe it's max length, max occurrences, required, etc.)
FormFieldConstraint - relates a constraint to a particular instance of a form field. This table combines a specific form with a specific field with a specific constraint. Note the metadata column; this potentially would be a good use for XML to store the specifics of the constraint.
Essentially, I suggest building a normalized database with few or no null values and no duplicated data. A structure as I've described would get you on the path to that goal.
I think if you need truly dynamic forms saved into a database, you'd have to create a sort of "dictionary" data table.
For example...
UserForms
---------
FormID
FieldName
FieldValue
FormID relates back to the parent form (so you can aggregate all of the fields for one form. FieldName is the name of the text field entered from. FieldValue is the value entered/selected for that field.
Obviously this isn't a perfect solution. You could have issues typing your data dynamically, but I leave the implementation of that up to you.
Anyways, hopefully this gives you somewhere to start thinking about how you'd like to accomplish things. Good luck!
P.S. I've found using webforms with .NET to be a total pain when doing dynamic form generation. In the instances I had to do it, I ditched it almost entirely and used native HTML elements. Then rewired my form by using the necessary values from Request. Probably not a perfect solution either, but it worked the best for me.
We created a forms system like the one you're describing with a schema very similar to the one at the end of Tim's post. It has been pretty complicated, and we really had to wrestle with the standard WebForms controls like the DetailsView and GridView to make them be able to perform CRUD operations on groups of answers. They're used to binding straight to properties on an object, and we're forcing them to look up a field ID in a dictionary first. They don't like it. You may want to consider using MVC.
One tricky question is how to store the answers. We ended up using a table that's keyed on FieldId, InstanceId (for example, if 10 people are filling out your form, there are 10 instances), and RowNumber (because we support multi-row forms for things like employment history). Instead of doing it this way, I would recommend making your AnswerRow a first-class concept with its own table tied to an Instance, and having the answers be linked to the AnswerRow and Field.
In order to support different value types, we had to create multiple answer fields on our answer table (AnswerChar, AnswerDate, AnswerInt, AnswerDecimal). Each of these maps to one or more Field Types (Date, Time, Number, etc.). Each Field Type has its own logic to represent the value in the UI, and put the value into the appropriate property on our answer objects.
All in all, it's been a lot of work. It's worth it for us, since this is the crux of the product, but you will definitely want to keep the cost in mind before embarking on a project like this.
I'm using jQuery, ASP.NET, SQL Server, and the other usual suspects to design a company CRM. After they put in contact info, notes, dates, places and so forth they have to be able to select many different people to be "CC'ed." A group of people will be required to be one either "CC'ed" or "ToDo." The rest of the people can be nothing or "CC" or "ToDo." Currently we have it set up as a huge databind to templates with radio buttons for each option. Looks like shit. Anyone have any suggestions? I'd like to use a template with a datasource and have a good way to retrieve their answers and use them.
I'm leaning jQuery direction but like I said I'll need there to be up to 3 possible options for the people. This is going to be all opinion so I'm just looking for options.
Just to re-clarify, this concept is similar to email but I don't want them to have to type anything in as it is a set group of names that they're allowed to select from.
Looking for quick simple and pretty. somewhere in the range of 120 names.
If you intend to look down the jQuery route, I suggest that this widget could possibly help you out (even if only for inspiration sakes). http://quasipartikel.at/multiselect/
I'm struggling to "visualize" your form for terms of "real-estate expendature" etc.
Not directly what you are looking for, but this plugin may help
http://devgrow.com/slidernav-jquery-plugin/
Typing with intellisense. Sorry - any graphical thing will look overloaded.
Or: A table with filter options on top (again, typing). THere simply is no other way.
What I would most likely do to achieve this is implement the auto filter pattern that you type in a text box a few letters of the name and then it would filter down all of the overall results to those containing that pattern. Then have a select all button that will let you check all of them, and then the user can manually uncheck a few instead of having to check all.
The other thing to do would be to offer some type of categorization of the data so that they could filter by category that would put people in probable groups that would want all them all together. Like IT, HR, Executive or something similar.
I'm wondering what would be the typical scenario for using an end-user report designer.
What I'm thinking of is to have a base report with all the columns that I can have, also with a basic view of the report (formatting, order of columns, etc.) and then let the user to change that format and order, take out or add (from the available columns) data to it, etc.
Is that a common way to address what is called end-user designer for reports or I'm off track?
I know it depends on the user (if it's someone that can handle SQL or not for example), but is it common to have a scenario where the user can build everthing from the sql query to the formatting?
Thanks!
Sebastian
The first thing I would think about is to put them in a very tightly controlled sandbox, both for security and also to prevent monstrous, server-eating queries. Beyond that, I think giving them a "menu" of limited options is a good path. I would not give them direct access to SQL.
First question is do you want users creating SQL that could become a run away query (think Cartesian join gone wild).
Depending upon your tooling you might want to publish your report as Excel. Creating a pivot table or a simple spreadsheet may provide the flexibility you are looking for but in a safe environment. Most users can handle removing columns, formatting, etc, in Excel and there are lots of self-help references that you might not find in a report writer tool.
I have an SQL database with multiple tables, and I am working on creating a searching feature. Other than having multiple queries for the different tables, is there a different way to go about said searching function?
I should probably add that a lot of my content is database driven to make upkeep easier. Lucene will not work for this, correct?
Different approaches to consider:
1) Multiple queries pre-baked, like you described.
2) Dynamic sql that you put together on the fly based on user-entered criteria.
3) If text is involved, based on SQL Server full text search or Lucene.
In my open source app BugTracker.NET, I do both 2 and 3 (using Lucene.NET).
I documented how I use Lucene.NET here:
http://www.ifdefined.com/blog/post/2009/02/Full-Text-Search-in-ASPNET-using-LuceneNET.aspx
Since you have tagged the question with Asp.net I suppose you want to search your webpages. In that case you can use Indexing Server to perform freetext searches easily that search the generated html and any keywords you have set up.
As Corey Trager suggested, using Lucene.NET is also an option. It has a good reputation of being fast and quite easy to use.
Although the other answers provide good suggestions such as using Lucene, I have much preferred using a custom caching method.
So for a website that I help create, we cached the searchable data every couple of hours, from many tables, into one simple table with columns such as:
URL
Item/Page Name
Main Keywords
Text Only Contents
Date Updated
I would then write my SQL statement to search this field using different functions to determin the rank.
You might want to check out this post i wrote on writing full text queries, its in C#, but its easilly portable, or just stick it in a library and use it as it.
How to build an SQL full text index search term in c#