Database Design For Status Field
Mar 1, 2007
Hello,
I have a database design question. I want to store a status in a table. In the ASP.NET interface for the user this status will be adapted to the language of the user.
This is how it would look like:
StatusID 1 = "yes" for English, "oui" for French, "ja" for Dutch
StatusID 2 = "no" for English, "non" for French, "neen" for Dutch
StatusID 3 = "error" for English, "erreur" for French, "fout" for Dutch
I don't want to do the translation in ASP.NET and it should be done in one query.
How would it look like in the database design.
View 5 Replies
ADVERTISEMENT
Jul 23, 2007
I have a design question that I was hoping you all can help with.
When I normally design a table I always make sure to include a status field. This way I can "delete" a record without actually having to delete it, just update the record to a status which signifies deleted. This ensures my users have an undelete capability as well as safesguarding against the "mad clickers" which click right through the "You are deleting this record..." alerts.
I have been recently adding tables which have temporary records and are meant to expire at a certain date. I have designed these tables to have an expiration date field AND a status field.
My question is this: What is the normal convention relating to these types of records/tables? Should queries using these types of tables query them using the status AND the expiration date? Should you create a job that updates the records status based on the expiration date being passed. Should you use a view that only displays current records based on expiration date?
I just want to make sure Im following standard practice as I design these types of tables.
Thanks for your help!
View 4 Replies
View Related
Mar 13, 2008
Hello,
I have a table which i use to queue messages in. in this table there is a status column along with all the other message colums (ID, body, phone, time, etc). I use tinyint to express the diffrent status values (my frist question is, should i continue using tinyint, or is there some sort of enum, or another suggestion?). the value 1 means its a new message. An external process polls this table and pics up messages that are new.
Some messages fail, and so their status is changed to two. An external post process comes along and does what it needs to with messages that have status' which it handles, for example message failures, it might erase it, or change its status back to 1.
I expect to handle thousands of messages per hour. Should I create another table, which has only id and status as columns. And when a message fails I will place it in here instead of placing it in my original table. then the post process only polls this table and joins with my main table. instead of having both processes poll the single table. Would this be more efficient for sql internal seraching? since it has a smaller table to search in? or does it not make a diffrence.
Thank you.
View 5 Replies
View Related
May 2, 2006
Dear All
Within the sysusers table there is a field named status... All the users has this field set to 2. However there is a particular user and the status for this user is set to 14. Does anyone knows what this means... i.e. why the status field is not set to 2 as it is for the other users?
Regards
Sandro
View 1 Replies
View Related
Apr 20, 2007
I am trying get the status field from the list of jobs in management. I have a activex script that queries system tables to find out if a job has failed and sends the report via e-mail.
Currently I use this query to get the names of jobs failed...
SELECT
name
FROM msdb.dbo.sysjobs A, msdb.dbo.sysjobservers B WHERE A.job_id = B.job_id AND B.last_run_outcome = 0
ORDER BY name
I need to add some criteria around the status field to get the appropriate results.
anybody?
Cheers :beer:
View 1 Replies
View Related
Feb 22, 2008
Hello,
We are trying to test for a field in our 'setup' table and no matter what we do it's has a personality of its own. It's the wackiest thing. The field has two steps in this update script - first we are checking to make sure the field 'set_fsm' is still in the table, if so then we are blanking out the field by updating the value to a pair of ' '. Next, after the field now has just a blank value we are going to change the data type from char(10) to a bit field. However, when we try to check the code the first time it works but every other time the update script runs it doesn't work. The code below are two approaches that we have tried with our general update tools that is run on each version / product release we have. Assistance is greatly appreciated.
The record doesn€™t exit yet it still falls into the BEGIN.
IF exists (select * from dbo.syscolumns where name = 'set_fsm'
and id = (select id from dbo.sysobjects where name = 'setup'))
BEGIN
PRINT €˜I am here€™
UPDATE setup SET set_fsm = ''
END
It won€™t print the €œI am here€? but still tries to update the table!!!
Here€™s the results:
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'set_fsm'.
Someone else said try this€¦
IF EXISTS (SELECT 1
FROM sysobjects o
JOIN syscolumns c on o.id = c.id
WHERE o.name = 'setup'
and c.name = 'set_fsm'
and o.xtype = 'U') -- because index columns are also stored in the sysobjects table
begin
print 'Found column'
update setup set set_fsm = ''
END
else
begin
print 'set_fsm column not found in table setup'
end
Same results:
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'set_fsm'.
View 3 Replies
View Related
Mar 26, 2007
Consider the following tableCustomercustId char(10)accountExpiryDate datetimeaccountStatus bitNow, I want to update the accountStatus to False as soon as thecurrent date becomes accountExpiryDate.I think it can be done using "SQL Agent" but my webhost doesnt provideme access to that. I have access only to the Query Analyzer.ThanksShane
View 12 Replies
View Related
May 11, 2015
I have table in which month & year are stored, Like this
Month Year
10 2014
11 2014
12 2014
1 2015
2 2015
3 2015
4 2015
I wanted a query in which it should return the value in a status field which has latest year & month.
View 9 Replies
View Related
May 13, 2015
I have a scenario like below
Product1
Product2 Product3
Product4 Product5
Product1 1
1 0 0
1
Product2 1
1 0 0
1
Product3 0
0 1 1
0
Product4 0
0 1 1
0
Product5 1
1 0 0
1
How to design tables in SQL Server for the above.
View 2 Replies
View Related
Dec 5, 2007
i am putting together an application for a client of mine that involves image heavy data handling. i have a couple of possible methods in mind of how to go about this, and would like some outside opinions, especially from any of you who may have done anything similar before.
to quickly sum up the application's desired results: a photo gallery that contains four sections of job before/after photos. 1)residential 2)comercial 3) automotive and 4)specialty. when a site browser clicks a section, it will bring up a gridview of the "key" or ideal photo (one each)from several different jobs. the site browser can then click the photo, and a new page (or new control, does'nt make much difference) will come up showing all photos for that particular job.) past and current customers will create user logins to have ability to upload photos of their specific job. admin needs ability to 1)upload photos for many jobs 2)review all photos before posting them to the gallery 3) would like to give admin ability to order the photos within the gallery and within each job 4)admin needs ability to create tagline with short description either for each photo or at least for each job.
as to the design of the data, i can either store the images themselves in the database, or create tables to tag the images with various identifying data, then simple store and call the images in a directory on the server. i have code to do either. i am trying to construct a database design to handle all issues. i like the idea of storing photos in the database more, just not sure how to architect it. it would be the 4 albums, each with infinitely create-able 'job' albums within, each job album housing job photos.
i am thinking the images maybe get a table for their specific info (ID as primary key, image itself, file type, length, and a foriegn key to a job table that has jobID primary key) the job table could have a job name that user inputs, thus identifying all photos to the same job. the job table would also foriegn key to the album table id, with its four categories of residential, automotive, commercial, and specialty. does this method seem feasible? if this system seems workable, i can throw in a boolean default to false for the admin to set true to display the job photos as a whole, with admin power to delete photos on an individual basis. but i am a little stumped how he can maybe order them? maybe an int field that he can edit and just manually put the jobs in the order he wants? and then put the photos under the jobs in the order he wants as well?
it seems i have somewhat thought this out just now while writing, so it seems i have a somewhat workable solution, if awkward, but if anybody knows a simpler, or tried and true, method, please let me know
any ideas, suggestions, and help is greatly appreciated.
View 23 Replies
View Related
Jul 20, 2005
I'm trying to create an OLAP system using SQL Server 2000 AnalysisServices (AS). I want the AS cube to be based on a database with astar schema.I have a field called Ratio. The initial ratio value is based uponthis formula: (CurrentTimePeriodAmount -PreviousTimePeriodAmount)/PreviousTimePeriodAmount. However, thatinitial ratio can be manually overridden and replaced. Then the ratiois used to calculate future Amounts.Should I place that calculated Ratio field in the "source" databasedesign or should it be part of the Analysis Services cube?
View 2 Replies
View Related
Nov 19, 2015
I have a table named [Customers] which has about 100 fields and tens of thousands of records. These fields have been created over a couple years, but now they are so disorganized its getting crazy. I want to move the fields using click and drag on the record selectors the GUI in design view of SQL Server Management Studio, but I am worried about possible dangers. Is there anything I should be worried about by doing this before saving the changes? I don't want to make a view because the front end program is pretty big and would require way too much reprogramming to point all its parts to a new view on a table used so much already.
The question arises because when I try, it wants to also save all tables that are FKs to this table, which are many(and have cascade updates on). So I decided to abort and get info I should know first. Although the data shouldn't change when moving the field, I don't want to just assume that nothing will go wrong.
Also, the system is live, and it isn't easy to shut down to do this change. Is it essential that the system be offline, or at least has no users connected to the tables?
View 3 Replies
View Related
Feb 13, 2002
Ok, I'm doing a football database for fixtures and stuff. The problem I am having is that in a fixture, there is both a home, and an away team. The tables as a result are something like this:
-------
Fixture
-------
fix_id
fix_date
fix_played
----
Team
----
tem_id
tem_name
-----------
TeamFixture
-----------
fix_id
tem_id
homeorawayteam
goals
It's not exactly like that, but you get the point. The question is, can I do a fixture query which results in one record per fixture, showing both teams details. The first in a hometeam field and the second in an away team field.
Fixture contains the details about the fixture like date and fixture id and has it been played
Team contains team info like team id, name, associated graphic
TeamFixture is the table which links the fixture to it's home and away team.
TeamFixture exists to prevent a many to many type relationship.
Make sense? Sorry if this turns out to be really easy, just can't get my head around it at the mo!
View 2 Replies
View Related
Jun 23, 2013
I'm designing a database that stores personal details of students and teachers for a school. I, wish to know if a there is away of formatting the bit data type to male/female. Cause i am only able to achieve 0 and 1 in this data type. So is there any way to change it, or is there any other data type suitable to provide only two options Also the database should be protected in a way that students may not be able to view or change. Only teachers/admin have the right to access/modify the data.
View 6 Replies
View Related
Oct 12, 2012
I ran into an interesting situation. I'm working on contract and was looking at creating an ERD for an existing database when I ran into a problem. I found FK's that are referencing columns that do not have a unique constraint or a unique index.Â
I don't know the history of the database but was there a time in SQL Server history where this would have been possible? I scripted out the tables and created it in a test database. When I run the script to create the FK I get the following message.Â
I double checked the original tables and this FK does exist in table1 and there is no unique anything in the referenced table, table2. Currently the database is running on SQL Server 2008 Ent.
ALTER TABLE [dbo].[table1] WITH CHECK ADD CONSTRAINT [FK_table1] FOREIGN KEY([Col1])
REFERENCES [dbo].[table2] ([col2])
There are no primary or candidate keys in the referenced table 'dbo.table2' that match the referencing column list in the foreign key 'FK_table1'.
View 4 Replies
View Related
Jun 13, 2015
I am designing a database. I want to define a automatic sequence on a table primary key field. what is the best solution for it?
I know I can enable identity property for a field, but it has some problems ( for example its seed jumps on restart and unsuccessful events)
I also can use some calculated sequences. for example I can calculate max of the filed values and after incrementing use it as key for new inserted record.
which one is better?
View 3 Replies
View Related
Feb 27, 2007
Hi is it possible to have a page of a website display the status of a database or MS SQL with .Net code ?, if so what code would i use. Any help would be appreciated.Thank You
View 6 Replies
View Related
Aug 23, 2001
I used the sp_msforeachtable stored proc to disable all triggers in a database. Once the command is complete, I want to see the statuses of all
these triggers . I am used to an Oracle database so I miss the data dictionary views that easily show this info. Also, I need to view the statuses of all FKs once they are all disabled as well.
View 4 Replies
View Related
Feb 14, 2008
Hello,
A hard drive crashed on one of our MS SQL Server 2005 and brought the server down
with it. We had replaced the hard drive and rebuilt the RAID 5 container and got the server rebooted.
However, one of the databases got corrupted after that. THis is the error logs snippet:
===============
,An error occurred during recovery<c/> preventing the database 'survey_p0765392' (database ID 439) from restarting. Diagnose the recovery errors and fix them<c/> or restore from a known good backup. If errors are not corrected or expected<c/> contact Technical Support.,
===============
We have backup which is 2 days old, and restoring from the backup would result in us losing a lot of records that we
have created since then. Is there any way to recover the data from this database? How canI repair it? Please advice. Thanks
View 5 Replies
View Related
Apr 21, 2007
Our database is running in full recovery mode and we backup the logfile every hour and the database file every night. I notice thetimestamp of database file *.mdf remains unchanged a few days. Forexample one database has its timestamp at Apr 15 while it is Apr 20already.I am wondering if this is acceptable. How do I force the system toflush the data and dirty blocks to the disk more frequently? What isthe downside to this?Thanks for any idea.
View 1 Replies
View Related
Jan 29, 2007
From SQL Management Studion I go to Management > Database Mail and I am trying to send a test email but I never receive anything. I checked my SMTP Mail Server Logs and I saw no entry of my test email.
I also I checked my SQL Database Mail Logs and everything seems fine, no errors are reported.
The msdb.dbo.sysmail_allitems shows my email status as "sent".
So what am I missing? What steps would you recommend for troubleshooting my problem?
Thank you,
Ric
View 7 Replies
View Related
Jun 4, 2008
Hi,
On my page I am using a wizard control with textboxes to collect data from the visitor.
When they click the finish button - this inserts their data into a Sql database.
On the form is a checkbox.
I dont know what type to use in the database column to accept this and also
how to configure the checkbox on the page so I know if its checked.
Also what would be inserted into the database column "yes" "no" or a numerical value??
Thanks for any advice?
amereto
View 1 Replies
View Related
Jun 15, 2006
Hi,
1) We will setup logshipping for a large database.
2) 2 systems are located at different city
3) Instead of use 'backup from primary and restore with norecovery to secondary ', we planned to use
SAN disk clone to get a second set of disks for related database files and log files.
4) We will mount the disk to the secondary server, however, how can we put the database on the new
server as 'norecovery' mode so that we can setup logshipping to this server ??
Another easy example is:
1) detach database
2) Copy database files to another disk
3) bring the disk to another city and attached to the new server
The database is recoveryed, how can we attach the database or mount the disk and make
the database as norecovery so that we can keep apply new logs??
For 2 identical database image, how can we toggle one from normal to norecovery to setup logshipping?
Is change 'status' from master database working?
Thank you very much for any words.
If this is the wrong forum, please point me to a correct one since I am new here and I can't find a
backup/restore related forum.
Jane
View 1 Replies
View Related
May 24, 2007
One of the database in our SQL Server 2000 environment is in the suspect status. We need to bring it back to the normal status.
The problem occurred because the disk on which the data file and log file for this database were placed ran out of space.
Pls note other databases in the same server are working fine.
Later on more space was made available on this disk. We tried the following options but with no success.
1. Reset the status of database and restarted the SQL Server. After restarting the SQL Server, the database once again was showing the suspect status.
2. Used the same data and log file in another SQL Server and attached with the database in this another SQL Server.
3. Tried dbcc chkdb with repair_allow_data_loss.
Since the database is in suspect status, we are neither able to export the data nor able to back up the database.
Please suggest some options to recover the database from the suspect status. Also it would be great if we can get the commands, scripts to find if the data/log file is corrupt and a way to correct it (even with data loss is fine).
View 9 Replies
View Related
Apr 23, 2007
Hi,
we have a reporting database that needs to be refreshed every week. I normally get a big backup file (50GB) from our business partner very Sunday morning; I have setup a job to restore the database once I got the backup file. The restore job normally will take about 4 or 5 hours to finish, but sometime it may take much longer (more than 10 hours). We knew there is some kind of disk storage contention going on the SAN. When this problem happens the system guy always try to pick my db restore process to be the victim. I hate to kill a job when it has 90% done, but I have no way to tell the restore progress status. Does someone know if I can query database restore progress information from any DMVs?
Thank you for your help in advance.
David Zhang
View 3 Replies
View Related
Jun 19, 2008
I restored a sql server database today. There is a problem though. In SQL server, right next to the name of the database are the words "Restricted User". Their seem to be some limitations on my access to this database now as I am not able to run some of my C# code against the database. How can I fix this in SQL server so that I am not a Restriced user.
Example of what I am talking about. In SQL server my database is named Gorlaz. Just to the left of this is a yellow Icon that represents the database "Gorlaz". For illustration purposes I will use the character "$" to substitute for the yellow database icon. So this is how it reads in SQL server management studio.
$Gorlaz(Restricted User)
View 3 Replies
View Related
Dec 17, 2001
I Restored the database from Backup with a Different database Name. I got a message the Restore Database was successful. Still the database has Loading Status. Can you let me know what I have to take that status.
View 1 Replies
View Related
Nov 24, 2015
i need a .rdl file for reporting..pull the data using below SQL scriptÂ
SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,Â
ind.name AS IndexName, indexstats.index_type_desc AS IndexType,Â
indexstats.avg_fragmentation_in_percentÂ
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstatsÂ
INNER JOIN sys.indexes ind Â
ON ind.object_id = indexstats.object_idÂ
AND ind.index_id = indexstats.index_idÂ
WHERE indexstats.avg_fragmentation_in_percent > 0.5Â
ORDER BY indexstats.avg_fragmentation_in_percent DESC
sql server 2008r2 Â database fragmentation report for .rdl file
View 7 Replies
View Related
Jan 12, 2013
I have a SQL cluster which ran out of disk the other day. I threw plenty more disk at the SAN. However, 1 of the databases came back with Recovery Pending and has been over 24 hours. I have tried to backup the database with no success. I don't have a clean backup from the day it occured so would have a good amount of work missing.
Running a dbcc check returns the following:
Msg 945, Level 14, State 2, Line 1
Database 'sqldb' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
I have not tried a dbcc check with REPAIR_ALLOW_DATA_LOSS as there seems to be a high risk of losing whatever was going on. how I can get the db back online?
View 10 Replies
View Related
Jan 22, 2015
I have a matrix table. These status can be changed by the user and I want to capture each change in database with out updating the earlier status
Pending
Activated
In PROGRESS
Submitted
Completed
Pending can be changed to submitted or completed. For one form there can be different status at different time. And each status must be saved in the database table. How can I design a table...
View 2 Replies
View Related
Mar 7, 2008
I want to customize database maintenance to run only on selected databases based on their status in sys.databases, without having to statically select them in the GUI.
I'm trying to write an SSIS package that will do the following:
1. Query for a list of databases that are not read-only or recovering, etc.
2. Perform database maintenance tasks (e.g., rebuild indexes) on those databases.
I'm doing this because the database maintenance tasks do not provide a way to select databases based on criteria or a SQL query filter.
My package includes an Execute SQL task to get the list of databases, a Foreach loop container to loop through the databases, and then...this is where I get stuck. I can't use the existing maintenance tasks (Rebuild Index, Update Statistics, etc.) because I don't know how to provide an input variable for the list of databases. I'd rather not write dynamic SQL to generate commands for each database object.
Does anyone know how to do this?
Thanks much.
David
View 9 Replies
View Related
Oct 29, 2015
I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?
View 6 Replies
View Related
Feb 24, 2006
Hello everyone,I have a webcontrol that uses database-structures alot, it uses the system tables in SQL to read column information from tables. To ease the load of the SQL server I have a property that stores this information in a cache and everything works fine.I am doing some research to find if there are anyway to get information from the SQL server that the structure from a table has changed.I want to know if a column or table has changed any values, like datatype, name, properties, etc.Any suggestions out there ?!
View 3 Replies
View Related