Solved

Help with Sql Tables

Posted on 2014-01-01
6
377 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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:
Scott Pletcher 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the proper way to use for criteria in left join? 7 25
Run SQL Server Proc from Access 11 28
SQL view 2 26
Sql Query 6 42
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…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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 SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

813 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

16 Experts available now in Live!

Get 1:1 Help Now