Relation between users with messages

Hello,
I have a table of Users:
create table dbo.User
Id int identity not null,
Name nvarchar (400) null,
// Other coluns as Login, Password, etc.
create table dbo.Role
Id int identity not null,
Name nvarchar (20) null
create table dbo.UserRole
UserId int not null,
RoleId int not null
Each user has one or more roles.
I need to relate users one to each other in periods of type.
For example, one professor to its students during 4 months in 2015.
And I also need to track messages between users.
One of my ideas would be the following:
create table dbo.UserToUser
FirstUserId int not null,
SecondUserId int not null,
StartDate datetime not null,
EndDate datetime not null
Being both ProfessorId and StudentId FK's of Users table.
create table dbo.Message
ToId int not null,
FromId int not null,
Text nvarchar(max) not null,
Created datetime not null
Being both ToId and FromId FK's of Users table.
Should this be done in another way?
Thank You,

Review the following design:
create table dbo.Users
Id int identity PRIMARY KEY,
Name nvarchar (400)not null UNIQUE,
-- // Other coluns as Login, Password, etc.
create table dbo.Role
Id int identity PRIMARY KEY,
Name nvarchar (20) not null UNIQUE
create table dbo.UserRole
UserId int not null REFERENCES Users,
RoleId int not null REFERENCES Role,
PRIMARY KEY (UserId, RoleID)
create table dbo.UserToUser
FirstUserId int not null REFERENCES Users,
SecondUserId int not null REFERENCES Users,
StartDate datetime not null,
EndDate datetime not null,
PRIMARY KEY (StartDate, FirstUserID, SecondUserID)
create table dbo.Message
ToId int not null REFERENCES Users,
FromId int not null REFERENCES Users,
Text nvarchar(max) not null,
Created datetime not null,
PRIMARY KEY(ToId, FromId, Created)
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

Similar Messages

  • Relation between BSEG with Asset Tables

    HI Guru's,
    how to find relation between BSEG with Asset Tables like ANLA and ANEP..
    regards
    JK

    Foreign keys
    - ANEP items are linked to ANLA via fields in common ANLN1 and ANLN2
    - ANEK header is linked to ANEP items via fields in common ANLN1, ANLN2, GJAHR and LNRAN
    - BKPF and BSEG are linked to ANEL ANEP via BUKRS, BELNR and GJAHR
    Optimization (as BSEG is behind a cluster table RFBLG)
    - Append BSIS (ZABSIS) and BSAS with ANLN1 and ANLN2, then create an index with these fields. As BSIS is filled via MOVE-CORRESPONDING statement, only a one-shot report to initially fill the new fields is to be developed. (look at old OSS [Note 62435 - F-03: Selection by purchasing documents|https://service.sap.com/sap/support/notes/62435] for optimization via purchase order)
    Regards

  • HT1203 How do you share between users with Windows 8

    I have two user accounts on my computer.
    How do I share my music between them with iTunes with Windows 8.

    There's a couple of ways to get through to the authorisation controls in the 11.0.x versions.
    The control is still in the Store menu, but first (if you're using iTunes versions 11.0.x) you might need to bring up the menu bar to see the Store menu.
    If you're using 11.0.x, click on the wee boxy icon up in the top-left corner of your iTunes to see the "Show Menu Bar" control, as per the following screenshot:
    Then you'll find the control in the Store menu:
    Alternatively, if you don't want to bring up the menu bar, it's still possible to get into the authorise controls via nested menus accessible from the wee boxy icon. Here's a screenshot of where to find them:

  • Problems to autenticate users with Messager Express.

    Greetings,
    I'm relatively new to iPlanet MS. I have IMS 5.1, Directory Server 4.13 and Delegated Administrator for Messaging and Collaboration 1,1.
    When I create an user into of a domain diferent to the default domain with iDA and I try the Messager Express with this new user, I receive the following error:
    Invalid user name or password
    This is the LDAP tree:
    org.org
    |
    Organization 1 (default domain)
    | |
    | People --- user1
    | Group
    | |
    | Organizacion 2
    | |
    | People -- user2
    Organization 3
    |
    People --- user3
    Any user who belongs to the organization 1 does not have any problem to use Messenger Express. If user1 send a mail to user2, user2 receive the mail. user2 (or user3) can to use Calendar Server, but does not the Messenger Express.
    How I can resolve this problem ?
    Thanks in advice

    Frank,
    First, since this is not the default domain, make sure you are logging in as: [email protected] ([email protected]).
    Second, take a look at the directory server access log and make sure it is searching for the user under o=org3, o=org.org.
    Michelle

  • Relation between ra_customer_trx_lines_all with mtl_system_items_b

    hi experts
    i need to join mtl_system_items_b with ra_customer_trx_lines_all, and it seems very easy but problem is .. my ra_customer_trx_lines_all.inventory_item_id is null and doesnt record any code but description is there.. what is this??? is this a kind of implimentation error ??
    can anybody tell me what to with that problem.
    regards
    anwer

    There can be different sources from where invoices can be created e.g. OM, Project etc. Also there can be different types of invoices. For all invoices Item number is not a mandatory column and description can be a free text.
    when creating a join between ra_customer_trx_lines and mtl_system_items make sure they have a outer join to get correct data.
    http://sureshvaishya.blogspot.com

  • Relation between user status & system status in maintenance notification

    Hi experts,
    I have maintained some user status in notification.My requirement is to block NOCO for notification until & unless user status "accepted by production" is set ,I have tried by putting "complete notification" as forbidden against the same user status"accepted by production" & check "set" button. Still system is allowing me to set "NOCO" even though I have not set user status as accepted by production, but after NOCO , user status is coming as accepted by production.
    How can I block to do NOCO if user status is not set as "accepted by production"?
    thanks in advance.
    rgds
    rajib

    Hi
    I have 4 user status prior to this user status "accepted by production"& in all these 4 user status I have put "forbidden", "set" & in "accepted by production" user status I have put "allowed" for "complete notification" business functionality .System is not allowing me to do NOCO for the 4 user status, but when I am manually keeping the user status "accepted by production", system should allow me to do NOCO which is not happening.It is throughing error message no-IM259,as mentioned below-
    Diagnosis
    This refers to an error in central status management.
    Procedure
    Please refer to your system administrator
    Pl suggest how to resolve this issue
    rgds
    rajib

  • Relation between BP with Organization

    Hi,
    Can any one help me by giving reference of any function module or table name so that I can get Organization Unit for a particular BP Number?

    Hi,
    You can make use of the table CRMV_BUT_SET0140 to find out the corresponding Org Unit data for a BP.
    On the other hand, in FM CRM_BUPA_CONV_EI2BAPI, for Set 140, there is subroutine call to
    execute set. Exploring this sub routine you will be able to find exact FM which updates the Org Unit data for the particular BP.
    I hope this information helps.
    Venkat

  • Relation Ship between User,Employee and Sales Person

    Hi All,
                 I am unable to find out the relation between User,Employee and
    Sales Person in Business One.I need to know what is the exact relation
    between User,Employee and Sales Person.I can't go further without knowing
    this relation in Business One.
                 I searched a lot regarding this relation in forums but i can't get a
    relevant answer.Please help me regarding this,<b>its an urgent requirement for
    me</b>.
    Regards,
    saleem

    1. check the forum - this question has already been answered several times
    2. read the guidelines for this forum

  • Relation between Shop id and Internet User in CRM

    Hi Guru's,
    We are using SAP CRM 4.0. Can you please let me know in SAP CRM backend how can i find the shop id from the Internet User. We have created a BSP application and hosted in Portal. In the BSP application we want to determine the sales area from shop id. I can see shop id stored in database table 'CRMM_ISA_SHOP_H' and function module 'CRM_ISAI_SALES_AREA_GET' to get the sales area from the shop id. But i am not able to determine the shop id from the logged in Internet User. Can you help?
    Regards,
    Priyank

    In your scenario, there is no relation between the Internet User and the Shop Id.
    In the web (ISA), Shop ID is determined as follows:
    1. It is either given as a parameter in the URL so that the user doesn't have to select it or
    2. If there is only one Shop, then there is no need. The application defaults to that. or
    3. If there are more shops,then  the user is presented with a screen to make the selection.
    You will have access to the Shop ID within the ISA Java-ABAP framework, but not in an independent BSP application such as yours. You have to make the user select the shop if there are multiple web shops.

  • Relation between CPU load and # of users

    Dear all :
    is their a relation between # of cpus and cpu load
    if i have 100 concurent user how many cpu should dedicated to it ?

    from where can i get benchmark?From your brain.
    If I give you a benchmark, it will be valid with my load, not yours. You need to create a benchmark that reflects your load.
    I have no idea what kind of load you have. Nor does anyone else ...
    ... unless you have a OTS or COTS application (Off The Shelf or Customized Off The Shelf). In which case your vendor (or developer) should have some clue.
    (Refraining from comments about the majority of developers ...)

  • After renaming my MAC hard drive, Acrobat, Illustrator and Bridge fail to launch. Acrobat returns the error message "An internal error occurred". I've checked this out and it seems related to user permissions. The version is Acrobat X. My machine has mult

    After renaming my MAC hard drive, Acrobat, Illustrator and Bridge fail to launch. Acrobat returns the error message "An internal error occurred". I've checked this out and it seems related to user permissions. The version is Acrobat X. My machine has multiple user accounts. Any help would be appreciated. I renamed the drive to its original name but to no effect. RR

    I resolved the issue.
    The problem is indeed a permissions issue with the Adobe Application Support folder.
    First, in MAC OS Lion the ~/Library/ folder is hidden by default. You must unhide it in order to proceed. (if it is already visible in your ~/User/ folder, proceed to Step 4.)
    Next launch the Terminal application.
    At the command line, paste the following command line: chflags nohidden ~/Library/
    Go to /Users/youruserid/Library/Application Support/Adobe
    Get info on the ~/Adobe folder and reset your permissions to read/write and apply to all enclosed folders
    Problem solved. RR

  • My Mac is doing strange things: delaying between users, mouse flickering and bouncing, gets stuck with rainbow wheel flickering. I ran the appel hardware test and it detected an error: 4MOT/4/40000003:HDD-1233 Does anybody know what that means? HELP!

    My imac is doing strange things:
    -delaying between users: when closing session it goes to blue, then takes a while to appear users signin box, and then wont recognize mouse command to enter until a couple of minutes later... then everything seems alright until....
    -it gets stuck between things, the rainbow wheel appears and its just delays there forever....
    -and every now and then the mouse starts flickering and bouncing wildly onscreen.
    I ran the appel hardware test and it detected an error:
    4MOT/4/40000003:HDD-1233
    Does anybody know what that means? HELP!

    WZZZ answered about where to get iStat. And do check the SMART status. If it is an overheating problem due to a fan or logic board problem, your hard drive is possibly cooking itself to death. If so it isn't a faulty hard drive even though the hard drive might fail. So assuming it's a temperature problem, even if you are able to repair things on the disk with software, that is working on symptoms, not causes. I could be wrong however.
    RE: AppleCare: Your iMac came with one year of AppleCare (Apple's warranty program), but within the first year you can buy 2 more years. You have to extend by the one year anniversary of purchase of the computer. Your 10,1 is too old to still be in the first year, and since you asked what it was, I'm sure you don't have it. Bottom line meaning is that whatever this problem turns out to be, you'll have to pay for it. Unless there is something like this. It is for 2011 iMacs with certain Seagate drives. You can put in your serial number for fun, but it looks like yours is too old. Lastly, some people have had Apple help them anyway if it is just out of warranty, but many have not. Your machine is one of these. Type in 10,1 in the search box. Is there an Apple Store near you? Just b/c it's out of warranty doesn't mean you shouldn't have it looked at by Apple. But no one here can say at all what Apple will or will not do.
    Hope you get it taken care of!

  • Yes another user with problem with Apple Mobile Device Support, I am getting the error message: Service 'Apple Mobile Device'(Apple Mobile Device) failed to start. Vertify that you have sufficient privileges to start system service....

    Yes another user with problem with Apple Mobile Device Support, I am getting the error message: Service 'Apple Mobile Device'(Apple Mobile Device) failed to start. Vertify that you have sufficient privileges to start system service....I hit retry and it came up again. I hit ignore and it prompted me to hit finish so Itunes can open.   I looked thru alot of these posts on here to try and resolve this problem myself but it's not working too well...I downloaded Itunes to my desktop so I can right click it with the program i downloaded called WinRAR. I extracted it and then went into the folder called Itunes64setup. I saw the file called AppleMobileDeviceSupport64 in there so I began to try and download it on it's own. Well that didn't work as I planned and got this error message:
    Apple Mobile Device Support wasn't installed on your computer. The installer encountered errors before Apple Mobile Device Support could be configured. Your system has not been modified. To retry these operations at a later time,please run the installer again.
    Well I tried to run it again and came up with the same message...I see that some people got great support to help them so I am hoping someone can help me as well. I know "b nor" is very qualfied and hopefully can help me! Please advise what I can do. Thank you

    Hi Iss9243,
    Welcome to the Support Communities!
    You've already tried some great troubleshooting steps, but the article below gives you quite a few more for this issue.  Hope it helps ....
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Cheers,
    - Judy

  • I have one iMac with 2 users. Will Home sharing allow me to share music between users? (running Mac OS 10.8.2

    I just seemed to get turned around when trying to share music on the same iMac.
    How do I share music between two different users with two different iTunes accounts on the same iMac. My wife and I simply want to be able to share music that she purchases with me and visa versa. We each have our own iPads and I am unsure of the proper way to do this so I don't messup the syncing of our iPads.
    Part of the reason I ask is that I see questions concerning two different computers. Does it make any difference that I am trying to share music between two users on the same iMac
    Thank you in advance for information helping me to understand the Home Sharing process.

    Hi, one question & one suggestion...
    What possible things are connected at home but not at the store, inlude every cable, etc.
    One way to test is to Safe Boot from the HD, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, Test for problem in Safe Mode...
    PS. Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive
    Reboot, test again.
    If it only does it in Regular Boot, then it could be some hardware problem like Video card, (Quartz is turned off in Safe Mode), or Airport, or some USB or Firewire device, or 3rd party add-on, Check System Preferences>Accounts>Login Items window to see if it or something relevant is listed.
    Check the System Preferences>Other Row, for 3rd party Pref Panes.
    Also look in these if they exist, some are invisible...
    /private/var/run/StartupItems
    /Library/StartupItems
    /System/Library/StartupItems
    /System/Library/LaunchDaemons
    /Library/LaunchDaemons

  • What's a good way to prompt a user with an error message etc. in swing?

    i want to be able to prompt the user within a given a function that i've created .. with some kind of warning message or error message .. or anything for that matter ..
    is there even a timer of some sort that i could use for the prompt .. say if im connecting and i want to prompt the user with a 'connecting ... ' message .. then close it when ive secured the connection? ...
    simple aesthetics i guess .. but a want indeed.

    For your first question, just use the static JOptionPane.showXXX methods.
    If you are making a connection in another thread, use the SwingUtilities.invokeLater (or in this case even invokeAndWait) method to close the dialog from the other thread.

Maybe you are looking for

  • New project

    my new project is to create a flash site for an resturant. the have an html site, that they don't want to chage. I am aloud to create a new home page that allows the user to choose between the two, or create a new html . I have complete control over

  • Late 2011 MacBook Pro (Mountain Lion 10.8.2) backlight keyboard not functioning properly?

         I have a late 2011 MacBook Pro running OS X Mountain Lion 10.8.2 and for some reason, the automatic backlight keyboard will not funtion as it should. When I have the "Adjust keyboard brightness in low light" option enabled in settings, and I tur

  • Video playback fullscreen

    While watching a video in full screen mode I press the pasue button and the whole movie window fades out and disappears. The normal functionality would be for the movie to pause. The movie then stops. No window or anything.The only way to start the m

  • Error while initializing ScriptUI :"Server initialization timed out!"

    Hey guys,      That's what I get when I open After Effects: and when I finish work and close the program I get the following: As you can see that's a Windows 7 OS 64 bit, although I think the problem is OS independent. Waiting for your replies!

  • Download page for trial version of Photoshop and Lightroom Mac OS 10.6.8

    Where can I find the download page for trial versions of Lightroom and Photoshop for Mac OS 10.6.8? It's so hard that Adobe has no contact form, no way I can see to contact them. The help is not helpful to me, it's more like an FAQ. So I'd also be in