Question : Sql Server 2008: User Schema vs. Column in table partitioning.

I'm tasked with building and designing a web application.  
This web application will have multiple clients (Referenced as "sites" moving forward).  
Each site has their own specific data.
Each site can have multiple users.
A user can have access to multiple site data.  
Each site will have the same database layout / schema.
The schema will have anywhere from 30-100 tables.
The tables could range from 60 records to 500,000+ records.
Certain users would be allowed to copy certain information from one site to another.
There could be a need for Reporting that aggregates data from multiple sites.

The question is, would it be better to make a user schema for each Site?  Or to append a "site id" column to every table and essentially replicate data used by each site in the table?  Maintaining a composite key (entity id + site id) across 30-100 tables could be a nightmare, but so could maintaining 10-20 user schemas and creating a new user schema for each client.

Do I have any other viable options?  Is one of the aforementioned options better than the other?

Thanks in advance.

Answer : Sql Server 2008: User Schema vs. Column in table partitioning.

I've done a bit of digging and I have attached a fragment from a class that saves a shopping basket in the session. Since shoving arrays in the session can be messy it converts the basket data (two arrays) to two strings and saves them in two session variables.

On the load of the next page, the class's initialisation checks to see if the session contains variables indicating that a basket is in use. If it finds them it uses UNSERIALIZE to unpack the strings back into arrays and then assigns them to class properties.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
// Store the current array in a session variable
	//
	private function updateBasket() {
		$_SESSION[$this->sessName] = serialize($this->basket);
		$_SESSION[$this->sessQty]  = serialize($this->qty);
	}



	// Initialise the basket
	//
	private function initialise() {

		// Check if session is in progress and if so retrieve the existing basket
		//
		if ( isset($_SESSION [$this->sessName]) && isset($_SESSION [$this->sessQty]) ) {
			$this->basket = unserialize( $_SESSION[$this->sessName] );
			$this->qty    = unserialize( $_SESSION[$this->sessQty] );
		}
		else {
			$this->basket = array();
			$this->qty    = array();
			$this->updateBasket();
		}

	}
Random Solutions  
 
programming4us programming4us