Sunday, February 19, 2012

[effeciency] specific result values

Hi.

I had no idea what to name the topic so I hope this is ok.

I feel like I am losing it, even though I am still learning SQL Server - I dont use it much in terms of technical/complex queries and so on but I do use SQL on a regular (almost) basis. I am all about making sure it is secure and effecient and performance and so on - just to give a bit of background about myself.

Say for instance I have an ASP.NET website, which I have developed a discussion board from scratch using SQL Server to store all the information.

Say for instance, we have a topic, and that topic will be "locked".

Would I be correct in saying that on such a table, "Topics", there should be a field which is known as "ActiveStatus" or "IsLocked", and depending on if the thread is locked or not, that value is set on the table field? Am I correct in saying this?

If not - then what is the correct way of stating/retrieving if the topic is locked, in other words, what is the best way to have control over the thread so you can lock the topic?

I cannot think of another way but to store this one value in SQL on this topic table, along with other fields. I would then get the result by calling the procedure from ASP.NET and accordingly, set an image button on the webpage to either "locked" or "post reply"

Sorry for being silly, but I want to confirm if I am about to do this correctly or not. I want to make sure I am doing the best practice all the time, and enjoy doing it naturally. What is the best design/decision on such a scenario/situation?

Many thanks for your input, I greatly appreciate it! :-)

You're not being silly at all.

It makes sense to add a column such as IsLocked or TopicLocked to your Topics table, preferably with a bit datatype, since the value will be either 1 for locked or 0 for unlocked. Then your web page can query that value and allow access to the topic or not.

Good luck with your application.

|||

Many thanks and yes I was also thinking of using the bit datatype

Thank-you! I just want to make sure im not being silly and missing something obvious :)

have a great day!

No comments:

Post a Comment