Solved

Help with Sql Tables

Posted on 2014-01-01
6
376 Views
Last Modified: 2014-01-03
Hello Experts,

I am creating a database (taking help from experts-exchange)
Currently I have these tables,

1.People
PeopleID
Name
isSuperAdmin

2.Society
SocietyID
SocietyName

3.SocietyPeople
PeopleID
SocietyID
IsSocietyAdmin

What I need to track is, which SuperAdmin created SocietyAdmin member.
And which SuperAdmin/SocietyAdmin creates society people.
(SuperAdmin can create member for any society while SocietyAdmin can create members for his society only)

My previous quetion is posted here,
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_28328699.html

Thanks in advance
0
Comment
Question by:johny_bravo1
6 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 39750636
I think you need this query:
Select SuA.PeopleID as SuperAdminID, SuA.Name as SuperAdminName,
SoA.PeopleID as SocietyAdminID, SoA.Name as SocietyAdminName
FROM People SuA INNER JOIN SocietyPeople s1 ON SuA.PeopleID = s1.PeopleID AND SuA.isSuperAdmin
INNER JOIN SocietyPeople s2 ON s1.SocietyID = s2.SocietyID
INNER JOIN People SoA ON SoA.PeopleID = s2.PeopleID AND s2.IsSocietyAdmin

Open in new window

0
 
LVL 12

Assisted Solution

by:Habib Pourfard
Habib Pourfard earned 250 total points
ID: 39750645
The tables you've designed aren't sufficient for what you need. you probably need another table to log who did what. like the one below:

Log
-----
ID
UserID
TableName
TableID
ActionType (Insert/Update)
Date
Notes
0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 39750650
Hi chaau,
Thanks for the reply.
I need to add a "CreatedBy" column to track who add the members.

(
Which SuperAdmin created SocietyAdmin
Which SocietyAdmin created SocietyMember
Which SuperAdmin created SocietyAdmin
)

How the tables should be changed?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Expert Comment

by:sarabhai
ID: 39750681
If you want to track which one is create by whom
Then need to add extra column to each table that need to be tract

CreatedBy as int
LastUpdatedBy as int
0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 39750986
Thank you experts.
What will the good approach :
1. Create a log table and put the entries for tracking who made the change
or
2. Put createdby in each table

e.g,

1.News
NewsiD
Title
Desc
ValidTill
SocietyId
CreatedBy (Better if we put it here and make relation with People?)

Or put the entry in log table?

There are other table also like Events/ Request and so on
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 250 total points
ID: 39752606
SocietyPeople ( PeopleID, SocietyID, IsSocietyAdmin,
    CreatedPeopleID, --person who created this row, whether admin or not
    MadeSocietyAdminPeopleID ) --(last) person who set "IsSocietyAdmin" to true
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now