472,780 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

The better of two table designs?

Hi all,

I am trying to mimic the unix security model (users and groups) in a web
app.

I have thought of two ways of implementing this, but am unsure which would
be better. The first design utilises three tables, while the second
utilises two tables, however one of the columns in the first table is an
an array.

Design 1:

CREATE TABLE users (
user_name varchar(31) UNIQUE NOT NULL,
enc_password varchar(63) NOT NULL;
);

CREATE TABLE groups (
group_id serial PRIMARY KEY,
group_name varchar(31) UNIQUE NOT NULL,
group_description text;
);

CREATE TABLE users_groups_union (
user_name varchar(31) REFERENCES users ON DELETE CASCADE NOT NULL,
group_id integer REFERENCES groups ON DELETE RESTRICT NOT NULL;

);
Design 2:

CREATE TABLE users (
user_name varchar(31) UNIQUE NOT NULL,
enc_password varchar(63) NOT NULL,
user_groups integer[] REFERENCES groups NOT NULL ON DELETE RESTRICT;
);

CREATE TABLE groups (
group_id serial PRIMARY KEY,
group_name varchar(31) UNIQUE NOT NULL,
group_description text;
);
So, my question is, which design will be better in the long run? I've used
a design similar to (1) before, but I have never tried holding arrays in a
column as in (2).... does this present any consistency issues? For
example, if a group is deleted, will pg check through all the values in
all the arrays to check that group_id was not in use?

Using design (1) I have to query two tables to check the password and
obtain the groups that the user belongs to, while with design (2) this can
be done querying just the users table. Presumably this has performance
benefits?

Thanks for any feedback,

Sam.
---
Posted via news://freenews.netfront.net
Complaints to ne**@netfront.net
Nov 11 '05 #1
0 1362

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Scotter | last post by:
Okay I think my title line was worded misleadingly. So here goes again. I've got quite 20 identical MDB files running on an IIS5 server. From time to time I need to go into various tables and add...
15
by: Holly | last post by:
I'm trying to get this page to look the same in Netscape and IE. I have a box that says 'Upcoming Events' on the lower left of the page. It's supposed to have a gray background, but in NS 4.x it...
8
by: Zero.NULL | last post by:
Hi, We are using Month-year tables to keep the history of long transaction of our application. For example: We capture the details of a certain action in table...
5
by: mm nn | last post by:
Hi, I want to create a table like this: ID Autonum Datefld Date Cat Text Itm Text tCount Number
8
by: Rob Mazur | last post by:
Hi. I'm trying to create a query that pulls information from 3 seperate tables. Here's how I want it to work: User is prompted for SSN Table 1: SSN Name Gender
1
by: elfyn | last post by:
I'm currently building a DB that you will keep track of vehicles, services to the vehicles and parts used for the servicing of the vehicles. I've created a table for Customers, Vehicles and...
0
by: Steve Walker | last post by:
A framework issue rather than a pure C# issue, so a little off topic, but the aspnet.webcontrols group is very quiet, and people here seem more experienced: I came across an irritating problem...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
0
by: service0073 | last post by:
Designs For Fine Jewelry Pieces Fine jewelry is created from the finest precious metals and the gems that are set in these metals could be what makes the jewelry so fine. Jewelry lovers can wear...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.