Data Model For A Web Messaging Application.
Jul 20, 2005
I need to develop an internal messaging sub-system that is similar to
a web mail application but without SMTP support (e.g message routes
are confined to the webapp domain). The requirements are rather
simple: Each user (e.g mailbox) can view incoming messages and his
outgoing messages. Message quota is defined as the sum of all incoming
and outgoing messages per user
and tracked in the users' row (Users table – log_TotalMessages). The
quota is enforced by the business logic layer and not by the DB.
I am considering the following data model for the storage component,
and would appreciate community feedback:
Table layout for incoming and outgoing messages
************************************************
CREATE TABLE [dbo].[Messages] (
[MessageID] [int] IDENTITY (1, 1) NOT NULL , // The messageID
[RecipientID] [int] NOT NULL , // The userid ('Users'
Table)
[SenderID] [int] NOT NULL , // The userid ('Users'
Table)
[GroupID] [uniqueidentifier] NULL , // Only assigned if the
user "replyed" to an incoming message
[SubmitDate] [smalldatetime] NOT NULL , // the date of the
message
[DeleteBySender] [bit] NOT NULL , // Since I want to maintain only
one copy of each message I mark a message "to be deleted" and delete
only if both are true.
[DeleteByRecipient] [bit] NOT NULL ,
[SeenByRecipient] [bit] NOT NULL , // Used to "highlight" unread
messages
[Subject] [tinyint] NOT NULL , // Subject is derived from a fixed
list
[MessageText] [varchar] (2000) COLLATE SQL_Latin1_General_CP1_CI_AS
NOT NULL
) ON [PRIMARY]
CREATE INDEX [Messages_RecipientID_IDX] ON
[dbo].[Messages]([RecipientID]) ON [PRIMARY]
CREATE INDEX [Messages_SenderID_IDX] ON [dbo].[Messages]([SenderID])
ON [PRIMARY]
/* Send Message */
CREATE PROCEDURE SendMessage (
@IN_RecipientID int,
@IN_SenderID int,
@IN_GroupID uniqueidentifier,
@IN_Subject tinyint,
@IN_MessageText varchar(2000),
@OUT_ERRCODE tinyint OUTPUT
)
AS
BEGIN TRANSACTION SendMessageTrans
INSERT INTO Messages
(RecipientID,
SenderID,
GroupID,
SubmitDate,
Subject,
MessageText)
VALUES (@IN_RecipientID,
@IN_SenderID,
@IN_GroupID,
GETDate(),
@IN_Subject,
@IN_MessageText)
UPDATE Users
SET log_NumberOfNewMessages = log_NumberOfNewMessages + 1
WHERE usr_AccountNo = @IN_RecipientID
UPDATE Users
SET log_TotalMessages = log_TotalMessages + 1
WHERE usr_AccountNo = @IN_SenderID
SAVE TRANSACTION SendMessageTrans
SET @OUT_ERRCODE = @@error
IF (@@error <> 0)
BEGIN
ROLLBACK TRANSACTION SendMessageTrans
END
ELSE
BEGIN
COMMIT TRANSACTION SendMessageTrans
END
/* ReadMessage */
CREATE PROCEDURE ReadMessage (
@IN_MessageID int,
@IN_RecipientID int,
@OUT_ERRCODE tinyint OUTPUT
)
AS
BEGIN TRANSACTION ReadMessageTrans
SELECT MessageText FROM Messages WHERE MessageID = @IN_MessageID
UPDATE Messages SET SeenByRecipient = 1 WHERE MessageID =
@IN_MessageID
UPDATE Users SET log_NumberOfNewMessages =
log_NumberOfNewMessages - 1 WHERE usr_AccountNo = @IN_RecipientID
SAVE TRANSACTION ReadMessageTrans
SET @OUT_ERRCODE = @@error
IF (@@error <> 0)
BEGIN
ROLLBACK TRANSACTION ReadMessageTrans
END
ELSE
BEGIN
COMMIT TRANSACTION ReadMessageTrans
END
/* Delete Message */
CREATE PROCEDURE DeleteMessage (
@IN_MessageID int,
@IN_DeleteIncomingMessage bit,
@IN_DeleteOutgoingMessage bit,
@OUT_ERRCODE tinyint OUTPUT
)
AS
BEGIN TRANSACTION DeleteMessageTrans
DECLARE @Recipient int
DECLARE @Sender int
SET @Recipient = (SELECT RecipientID FROM Messages WHERE MessageID =
@IN_MessageID)
SET @Sender = (SELECT SenderID FROM Messages WHERE MessageID =
@IN_MessageID)
IF (@IN_DeleteIncomingMessage = 1)
BEGIN
IF((SELECT DeleteBySender FROM Messages WHERE MessageID =
@IN_MessageID) = 1)
BEGIN
DELETE FROM Messages WHERE MessageID = @IN_MessageID
UPDATE Users SET log_TotalMessages = log_TotalMessages - 1
WHERE usr_AccountNo = @Recipient
END
ELSE
BEGIN
UPDATE Messages SET DeleteByRecipient = 1 WHERE MessageID =
@IN_MessageID
UPDATE Users SET log_TotalMessages = log_TotalMessages - 1
WHERE usr_AccountNo = @Recipient
END
END
IF (@IN_DeleteOutgoingMessage = 1)
BEGIN
IF((SELECT DeleteByRecipient FROM Messages WHERE MessageID =
@IN_MessageID) = 1)
BEGIN
DELETE FROM Messages WHERE MessageID = @IN_MessageID
UPDATE Users SET log_TotalMessages = log_TotalMessages - 1
WHERE usr_AccountNo = @Sender
END
ELSE
BEGIN
UPDATE Messages SET DeleteBySender = 1 WHERE MessageID =
@IN_MessageID
UPDATE Users SET log_TotalMessages = log_TotalMessages - 1
WHERE usr_AccountNo = @Sender
END
END
SAVE TRANSACTION DeleteMessageTrans
SET @OUT_ERRCODE = @@error
IF (@@error <> 0)
BEGIN
ROLLBACK TRANSACTION DeleteMessageTrans
END
ELSE
BEGIN
COMMIT TRANSACTION DeleteMessageTrans
END
/* ListIncomingMessages */
CREATE PROCEDURE ListIncomingMessages (
@IN_RecipientID int
)
AS
SELECT SenderID, MessageID, SubmitDate FROM Messages WHERE RecipientID
= @IN_RecipientID AND DeleteByRecipient = 0 ORDER BY SubmitDate DESC
/* ListOutgoingMessages */
CREATE PROCEDURE ListOutgoingMessages (
@IN_SenderID int
)
AS
SELECT RecipientID, MessageID, SubmitDate FROM Messages WHERE SenderID
= @IN_SenderID AND DeleteBySender = 0 ORDER BY SubmitDate DESC
Thanks in advance!
-Itai
View 4 Replies
ADVERTISEMENT
Apr 4, 2007
Hi all,
I have a datamining model and i want to show the model parameters on a webpage. The model is a decisiontree. Is there a method i can use to show a formula of the decisiontree on a page or is a visual representation the only solution to visualize the tree?
How can i visualize the tree? Can I use the data mining add-ons for office 2007 to make a tree in visio and afterwards publish the tree on a sharepoint site? If that is possible is the visualization dynamic, if the model changes does the visualization changes too?
The data mining viewers i think, i can't use because there work only with windows forms. Are there other methods to visualize a decision tree on a webpage?
Thanks,
Dennis
View 6 Replies
View Related
Dec 28, 2007
HI
Thanks a lot for your answer
I say my request but I don€™t know why anybody don€™t answer me
I have a project about predicting a value about selling and buying of a good like t-shirts and I use data mining for my project ,so I should use time series algorithm ,that €˜s mean I have previous data about t-shirts for 11 months ago and now I should say for 12th month ,how many t-shirts are sale?
My tables saved on the excel file and it is problem, because how should I use this table for building model?
After building a model and structure and predicting the value of 12th month for this store in the mining model then I use this query in model in bi:
€œSELECT
PredictTimeSeries(amount)
From
[Forecasting]€?
This query showed a column and prediction value.
After all of that now I should show this value in the application so I use c# language for building it, so I use a form in c# then I add a button to form that with clicking on this button, I can connect to my structure and then show process of connecting in the panel, then with clicking on the other button I can use this query
(€œSELECT
PredictTimeSeries(amount)
From
[Forecasting]€?
) and after using I can see prediction value in the textbox, that€˜s mean the value of 12th month show on textbox.
Form has two buttons: one button is for connecting to mining structure and other button is for sending PredictTimeSeries query to structure, one textbox, which is for showing the predicting value for 12th month for selling t-shirts, one panel for viewing the lift chart.
Also you say
You are building an application that programmatically creates mining structure and a model, and then you want to train the model and display some results.
And I don€™t know how can I train my model, I should use a special code for it?
If your answer is say, please explain that and then say that codes are for training.
Please if you can send c# code for Sporadic of stage, please send that, I need to this code; my request is emergency for me.
Thanks a lot
i am very sad because any body don't answer me
View 1 Replies
View Related
Oct 23, 2000
Need Some Help. I'm new to SQL Server 7.0., and I'm wondering if the application can do what I need it to do. I've got a stand alone third party program that updates a SQL 7.0 DB, and what I need is: When an update happens, is there any way to 'let another program know' that an update has occured and what the data is? I would hate to have to write an SQL clause to constantly 'poll' the DB looking for an update, this seems silly. Simply I need some way to know if table X has been updated, and what was the update? Any help would be greatly apprec... KT
View 1 Replies
View Related
Oct 23, 2000
Trigger seems to work fine, however, the Online Books state you can find out what data was actually modified when the trigger fired, but I can't seem to find out how to do it. Any Ideas Apprec.. Thanks.. KT
View 1 Replies
View Related
Dec 5, 2005
Running 2005 Beta 3 Refresh. When I first deploy, it works fine. Subsequent deployments yield the following error:
View 9 Replies
View Related
Mar 3, 2005
Hello All,
Does anyone know if it is possible to send a text message to a phone number via a DTS package or job within SQL Server. For instance, if a job fails a text message is sent to a user.
Thanks, Gary
View 2 Replies
View Related
Dec 2, 2006
Hi All, i am trying to host the system.messaging.dll in SQL Server. I get the usual warnings about not being fully trusted. I am prepared for MS not supporting. But, when i execute my trigger (which writes to message queue), the trigger fails with an exception of 'That assembly does not allow partially trusted callers'. So. is there no way for me to write to MSMQ using triggers? Do i have to rethink my strategy?
imports System.Messaging
Dim msmq As MessageQueue = MessageQueue.Create(".TestQueue", False)
msmq.Send("Test")
Thanks for the help
View 5 Replies
View Related
Dec 22, 2000
Hi
I have Outlook 2000 and SQL 7 .. do I need Window NT Messaging and Exchange Server to configure a profile for the mail to work ???
thanks in advance for the answer
View 2 Replies
View Related
Jul 21, 2015
I'm in the process of building messaging functionality in to my application where by users can contact one another, look at it as a dating site, you click on someones profile, view their profile and then send that user a message.
I started to build the table which looked like this:
Id (PK) (Increments by 1)
ToUserId (FK) -- User who they're getting in contact with
FromUserId (FK) -- User who sent the message
Content (nvarchar(3000)) -- Message being send
Status (int) -- read / new / deleted / sent
EmailDate (datetime)
EmailDeleted (datetime)
But the problem with this setup is both user's maybe sending / replying to each other so I would have multiple entries / statuses in one table which may become a nightmare to manage / control.
View 9 Replies
View Related
Feb 14, 2007
hey all you database guru's hopefully someone can lend some insight as to a little table design problem I have.
Basically I've got a system in place to authorize users to access a website typical username password stuff. The table contains a list of users and there passwords plus the auth level and a few other tid bits that aren't really important enough to into detail about them here. What I want to do is add a messaging system to this, I think I could probably figure out a way to do this half decent if I setup a seperate table for each user to add a row to the table for every message entry than in my asp.net code have it delete everything but the last 10 entries every time a user logs on. However I would much prefer a way that I didn't have to setup a whole new table for each user just for messaging purposes, maybe store something like a list in one of the database cell's kind of like .nets generic.list or better yet generic.queue, I would also like a way if it's possible without too much work to have the table automatically delete the oldest message every time a new message is received if there's already 10 messages existing for the user.
Anyways hopefully someone has some experience in setting up a system like this, I don't really require any code samples I can code it all myself (other than the database code to automatically remove entry's, I'm not a database guy) if someone could just explain a way to accomplish what I'm trying to do, or if someone has a different more convenient way of doing this I would be up for suggestions
Thanks in advance for any help offered, I do appreciate it
View 3 Replies
View Related
Oct 12, 2015
I've question about how to handle structural datamodel changes in a datasource of PowerPivot. Suppose I'm developing a starmodel in SQL Server and sometimes a datatype changes or a name of a field changes in a table. It seems to me that PowerPivot handle this not gracefully as Analysis MD does (mostly). I received an error because of a wrong fieldname or even no error when a dattype changes in PowerPivot. Is this common or do I something wrong here. Does this mean that every time the datamodel changes the PowerPivot should be recreated? Or am I missing the clue here?
View 6 Replies
View Related
Apr 22, 2015
I am getting ErrorCode 8 while loading the data from stage to model. I have checked my error view it states that "Member Code is Inactive".
Initially I have loaded same set of data in Model from MDS Stage table but then deleted with ImportType = 5 which removed all the data from the MDM model.
Now i want to load it back but its giving the Error Code 8 .. Before loading the same data i have changed the stage table Importtype to 2 and Importstatusid to 0.
View 6 Replies
View Related
Sep 10, 2013
I don't know if the question has been nailed down. Aside from deleting tables, can we delete the *content* of data within the tables. It doesn't seem crazy that, if you can pull in data from a feed then you should be able to remove the content out again (without also destroying the user's meta-data work ). Reasons for this include:
- Security (a user may not have rights to see *my* data and should go refresh their own)
- Size (workbook doesn't need to have GB's of irrelevant data saved to disk in a workbook if it was just useful during development phase to a pre-production data feed)
- Bad data (pre-production data feed is not good data)
- User-friendliness (data feed was refreshed 2 years ago and workbook was saved to file server. Users shouldn't be presented with irrelevant data, but should get empty pivot tables until they go do their refresh)
Obviously Excel internally knows how to clear out PowerPivot data, given the prompt shown here: [URL] ....
But how does a user initiate this on their own (corruption aside)?
Previous time this question was asked, without a real resolution: [URL] ....
View 8 Replies
View Related
May 17, 2007
Hi,
I am finding nice examples data model of CMS. Do you know any link to data model phorum or any link to data model examples(nice)?
Thanks
View 3 Replies
View Related
Jun 16, 2008
Why would we need to know the data model to write queries?
Sorry but its been a long time since I've worked with databases and I don't remember!
Could anybody lead me in the right direction please?
View 1 Replies
View Related
Jun 16, 2008
Why would we need a data model to write queries?
Sorry but its been a loong time since I've worked with databases and I barely remember.
Could anybody lead me in the right direction please?
Thanks.
View 1 Replies
View Related
Oct 19, 2015
I need to develop a language specific dwh, meaning that descriptions of products are available from a SAP system in multiple languages. English is the most important language and that is the standard. But, there are also requirements of countries that wants productdescriptions in their language.Â
Productnr Productdesc Language
1       product    EN
1       produkt    DE
One option is to column the descriptions, but that is not very elegantly. I was thinking of using bridge tables to model this but you have to always select a language in a filter (I think)..
I'm thinking of a technical solution, such that when a user logs on, the language is determined and a view determines whether to pick a certain product table specific for a certain language. But then I don't have the opportunity to interchange the different language specific fields in a report (or in my case PowerPivot).
View 2 Replies
View Related
Apr 25, 2008
We have the following scenario,
We have our Production server having database on which Few DTS packages execute every night. Most of them have Bulk Insert stored procedures running.
SO we have to set Recovery Model of the database to simple for that period of time, otherwise it will blow up our logs.
Is there any way we can set up log shipping between our production and standby server, but pause it for some time, set recovery model of primary db to simple, execute DTS Bulk Insert Jobs, Bring it Back to Full recovery Model AND finally bring back Log SHipping.
It it possible, if yes how can we achieve this.
If not what could be another DR solution in this scenario.
Thanks Much
Tejinder
View 6 Replies
View Related
Aug 2, 2007
Hi,
I have been given the assignment to come up with an Entity Relationship diagram of an existing database. The database wasn't designed by me. I was wondering if there is a standard scientific way of displaying the relationships between the various tables at a functional level on Visio. Since, I didn't design the database in the first place, I don't know how to take a step backward and recreate the ERD from the given database.
Any help will be appreciated.
thanks
View 4 Replies
View Related
Sep 28, 2007
Hi,
I would like to know best way to design the database for the following requirement. I have a collection of tree nodes. each node has a type and set of attributes and a parent node (except for the node which has no parent). node type refers to the level of the node in the tree. child node inherits the attributes from the parent node (similar to object oriented programming where derived class inherits properties of the base class). user can add/update/delete nodes from the tree and user can choose to override the attributes of the parent node in child node.
what is best way to store this type of data? should there be a separate table for each node type (level in the tree). but the problem with this approach is that we need to duplicate the columns of the parent node, because user can overwrite the parent node attributes in the child node. there can be more than one at the same level and all of them share same set of attributes. this concept is exactly like inheritance in object oriented programming. as far as the data is concerned, there are around 15 levels, around 30K nodes and 30 attributes spread across different node levels.
thanks,
RK
View 1 Replies
View Related
Jan 24, 2007
This may be a noob question... but I am not able to create a data model and its frustrating me. :)
I made the Data Source... I made the Data Source View (just grabbed a table) and made the report model... but the model is empty >< When it autogenerated the model, it did yell at me about the table not having a primary key... do all the tables have to have primary keys???
Please help I'm a bit lost.
View 2 Replies
View Related
Jul 31, 2007
I am trying to do the examples using SQL Server 2005 Reporting Services (2006) by Brian Larson.
The example says to use GDS as the data source yet all I see is Adventure Works.
The tables for AW are not the same as the tables for GDS.
Is there something I need to do or does the DBA need to install something else.
View 1 Replies
View Related
Sep 20, 2005
What is the better table design for a data collection application.1. Vertical model (pk, attributeName, AttributeValue)2. Custom columns (pk, custom1, custom2, custom3...custom50)Since the data elements collected may change year over year, whichmodel better takes of this column dynamicness
View 7 Replies
View Related
Jan 11, 2006
I am new to SSIS programming, so bear with me if my question seems naive to you gurus. I have a situation that needs to set the data source for a data flow from external .NET application ('external' means that the application will run on different process than the SSIS). I am trying to set the data source on which the data flow works from my C# application in a DataSet format. Ideal solution is not to save the DataSet to any file on harddisk (I know that will work, but has the overhead of writing, reading and managing the temp file). What I want to achive is that the business logic of picking data for SSIS Data Flow to process is controlled inside my C# application, the Data Flow just does what it does best - Transformation. Have any of you successfully done this before?. Thanks!
View 1 Replies
View Related
Dec 21, 2006
Hi, new to this forum. I have a data model that I'm curious about, because it has a structure that's new to me:
TableA -- TableB -- TableD
TableA -- TableC -- TableD
TableB and TableC each model a many-to-many relationship between TableA and TableD.
In addition to being new to me, it might also be the causing us problems with our code generator (a product called .netTiers).
Anyone used this construct before, or suggest an alternative?
Dave
P.S. Data model is attached
View 1 Replies
View Related
Feb 22, 2007
I have been generating report models for users to use with Report Builder and there is no data when they select the model. I noticed that the tables I chose did not have a primary key and when I chose a different table, with a primary key, and generated a model from it, then there was data for the user to use in Report Builder.
Is there a documented work around or will I need to set a primary key on each table?
View 3 Replies
View Related
Sep 24, 2007
I am trying to applying an data filter that will filter out user based on userid
Three tables:
tblPerson (fact table): contains over 1 million records with about 20 fields. One of the fields is called BureauID (int). BureauID indicates what Bureau the person works in for an given record.
tblBureau (attribute table) which has a FK relationship to tblPerson) contains the following fields:
BureauID int - this is the linked field to tbl person
Bureau Code varchar
Bureau ShortName varchar
The reason we use tblBureau as in attribute table instead of place the bureau code and short name directly into table Person is so that we index tbl person quickly with "ints".
tblDataAccess, which has two fields loginID with bureau Code. The bureau code in this table tells me what bureau that userid has access to.
How do i get the report model to filter based on this userid????. I know i have to add some data filters but i am not sure where.
I put an filter on DataAccess so that login = getuserid().
But what do i do to table person or table bureau, so that a person can only see the people in there bureau.
Thanks for you help
Ryan Swann
View 5 Replies
View Related
Feb 1, 2008
Hi,
I created a report model using reporting services, deployed the model locally and then built a report based on that model. The report works fine, but any data updates don't show up, seems like data is cached. I bounced reporting services, cleared cached tables in ReportServerTempDB but of no use. Has anybody faced this problem? How can I get updated data for reports built through a report model. Any help is appreciated.
Thanks,
Sri
View 4 Replies
View Related
Sep 29, 2015
I followed the tutorial posted at [URL] ...
Everything was ok until the last step where I had to process the mining structure which resulted in a warning
"Informational (Data mining): Decision Trees found no splits for model, Tbl Decision Tree Example."
What does this error mean? How do I resolve it? Also, I only see the first level in the Mining Model Viewer, I don't see the levels 2 and 3.
View 2 Replies
View Related
Apr 22, 2008
I have an opportunity to rebuild a database model with the express purpose of improving query performance. So given the following I have a few questions.
Table A (~500M records)
Primary Key Field (int)
Field 1 (varchar)
Field 2 (varchar)
Field 3 (varchar)
Field 4 (varchar)
Field 5 (varchar)
Table B (1B+ records)
Primary Key Field (int)
Foreign Key Field (int)
Field 1 (varchar)
Field 2 (varchar)
Field 3 (varchar)
Field 4 (varchar)
Field 5 (varchar)
* Assumed: Tables are inner joined on all queries. The database is readonly.
-- Most of my lookups are based on querying Field 1 of Table A. The data content of Field 1, Table A is 90% unique.
1) Would it be more beneficial to put the clustered index on Field 1 instead of the PK field in Table A?
2) Can an Identity column be non-clustered?
3) Alternatively, would it be beneficial to build a separate lookup table with just the PK & Field 1 of Table A, with a clustered index on the lookup table Field 1 which I join on Table A? (did that make sense?)
-- I have a secondary lookup that performs queries on Fields 1, 2, 3, 4 & 5 of Table B
1) Would it be more beneficial to create an additional indexed lookup column of the concantenated values of Fields 1-5 of Table B versus a covering index of all 5 columns?
2) Does a clustered index have to be unique?
3) Would a clustered index be more beneficial over Fields 1-5 or the special lookup column versus the PK or FK fields?
4) Would creating a special lookup table with just the requisite fields be more beneficial?
An extra question. The existing data model uses the CHAR datatype for all columns less than 9 characters wide and the columns are set to allow nulls. This requires every select statement to COALESCE() and RTRIM() all these columns. I intend to make all (affected) columns VARCHAR, NOT NULL with a default value of a 0-length string.
Will this enhance query performance?
Thanks in advance for any insight.
View 7 Replies
View Related
Jan 3, 2014
I'm going through a very tedious process of documenting tables and fields for a third party database, with an eye toward creating lots of SSRS Reports. I'm making progress, but I was wondering if there's a slick way to export all the tables, fields and key relationships.
View 3 Replies
View Related
Aug 14, 2007
Hi all,
I am having data model diagram containing 150 odd tables in MS Office Visio 2007.The Datamodel Diagram even has the Relationships between the Tables.
Do we have any Procedure to export the Datamodel Diagram from the Visio to the Sql Server carrying all the relationships.
We are having the reverse engineer procedure to export database diagrams from Sql server to the datamodel diagram in the Visio in the same way, do we have any procedure to Export DataModel diagram from Visio to SQL Server to create tables with all the relationships?
View 1 Replies
View Related