database

MySQL + PHP: General Help Needed for Echoing Data from Foreign Key

I have 2 tables (Users, Wall). The UserID in the Wall table is a foreign key. How would I go about fetching the users details using this? (I want to fetch the users Forename and Surname who posted the message.) Users Table: Wall Table: EDIT: I cannot figure out how to show the data. <?php include('config.php'); ?> <!DOCTYPE html PU...

modeling a "one-to-one" relation in a database is the same than modeling "inheritance"?

Hi, i was wondering if there's a difference between modeling a one-to-one relation and a inheritance relation (Table-Per-Type) In both cases we add a foreing key with a UNIQUE constraint, or somethimes the FK is part of the PK It seems to me that the table structure is the same, but maybe i'm missing something. Thanks in advance. ...

SQL Joins query not acting as wanted.

I have the following tables: CREATE TABLE `attendance_event_attendance` ( `id` int(11) NOT NULL AUTO_INCREMENT, `talk_id` varchar(200) NOT NULL, `membersAttended_id` varchar(200) NOT NULL, PRIMARY KEY (`id`), KEY `attendance_event_attendance_9ace4e5a` (`talk_id`), KEY `attendance_event_attendance_3c0dadb7` (`membersAttended_id`) ) ENGI...

Question about DB of social networking websites

Like facebook, everyone has messages on the wall. Are all messages stored in only one table? And it will only display messages belong to the user's ID when loading the page? And if it is then there will be so many rows in that table. Is there any limit of the rows in one table? Or every user has one table only store their own messages? ...

how to represent trees and their content in MySQL?

I need to be able to store something like this: where the green is a template type, the gray is a field container type, and the white is field. (That being, a field has a label and some text, both mediumtext for simplicity; and a field container can store other field containers or text, and a template is a top-level field.) Now, let's...

Conditional Columns - MySQL query

I need to display a particular column in my SQL result only if it is not null. If it is null, I don't want that column to appear at all in my result. Is there a way to express this condition in SQL? ...

Why does my DB project's .dbmdl file change even when I make no changes to the project?

I'm running into a small but weird annoyance that seems to be happening to other people, too (for example, check out the revision history of SEDE). I have a SQL Server 2008 database project in Visual Studio 2010 that works properly. When I go to commit/checkin to source control, I'm told that my DB project's .dbmdl file has changed, even...

Getting Root & Leaf Nodes for a Given Id - How to?

Assume I have a table that has the following structure: ================= | Id | ParentId | ================= | 1 | 0 | | 2 | 1 | | 3 | 1 | | 4 | 2 | | 5 | 2 | | 6 | 3 | | 7 | 3 | ----------------- This results in a tree like this: 1 / \ 2 3 / \ / \ 4 5 6 7...

Cannot Drop Database after Unit Test

ANSWER: I wasn't clearing my ConnectionPools. The solved scenario is: SetUp: Check to see if the 'TEMP_NUnit' database (SQL Server 2005) exists on the local instance If it exists, drop it. Create a new blank database named 'TEMP_NUnit'. Test: Instantiate the 'Upgrade Database' component. Check that essential properties of compone...

SQL - How to join top ordered results from pictures table with product table ?

I have a products table, and a pictures table as such: Products id name model Pictures id pid url order The picture for each pid with the highest order is the cover picture. There can be more than 1 picture per product. I want to join this result when I query the products, so it would show these r...

Open Source Data Migration Tool

Hi My requirement is I need to migrate Data from Mysql to Postgres. Is there any free Data Migration tool which could do this effectively. I have some huge data in MySQL which I need to convert to Postgres Db. Henceforth I am looking for a Data Migration tool which could migrate tables (along with indexes, constraints etc) and data. I...

ASP.NET/IIS7 - Securing access to SQL Server for multiple user roles

I'm working on an web application using ASP.NET 4.0, C#, and IIS7. The web application is a content management system that defines multiple user roles, such as editor and administrator. These users and roles are managed by the asp.net membership framework, and the associated database tables are integrated into the web app's database usin...

why must a primary key be minimal?

A primary key is an attribute or set of attributes that uniquely identifies a row in a table. But a primary key has not only to be unique, but also minimal. Why is that necessary? ...

java ORM for a read only DB

Hi all, I know hibernate but I wonder if there would be a lighter ORM engine for a read only database. I mean, I don't need some transactional queries or to update some records. On the other side, I need to handle some large list of records: List<MyRecord> list= object.getMyRecords(); // list.size() > 1E7 Does such engine exist ? Man...

consitent vs peformance database design for db polymorphism with versioning

I need to create a database for 2 types of farmers (organizations and landlords) which have different columns that need to be stored and I also need to version their info. One db design that I came up with is this: (the consistent one) Farmers Id FType check(FType in ('organization', 'landlord')) Unique(Id,Ftype) Organizations Id ...

SELECT Data from xml variable

I done with this but still no expected result out through this proc DECLARE @nvarval NVARCHAR(max) DECLARE @xmlval xml DECLARE @tblxml TABLE(xmlfld XML) SET @nvarval='' SET @nvarval =@nvarval + '<ROOT>' SET @nvarval =@nvarval + ' <Customers>' SET @nvarval =@nvarval + ' <CustomerId>1111</CustomerId>' SET @nvarval =@nvarval + ' ...

Database Design: Defining Access Control

An application I am developing needs to provide access to data based on a list of cities defined for each client. A client can have: access to all cities in a country OR access to all cities in a state / region OR access to select cities in any state or country. What would be the best way to define this in the database (if the db has...

MySQL : Multiple row as comma separated single row.

Hi, I have two tables : DISH and DISH_HAS_DISHES. Dish table has all the dishes and "Dish_has_dishes" table has a one-to-many relationship with "Dish" table. I.e. a dish can have multiple dishes. For example DISH : dish_id dish_name 1 dish_1 2 dish_2 3 dish_3 4 dish_4 DISH_HAS_DISHES : meal_id d...

How to display out image into Listview from DB?

I successfully inserted my image data into a database. However, currently I am having problems with showing it on the Listview. setListAdapter(new SimpleCursorAdapter(this, R.layout.view_list, c, new String[] {"date", "title", "mood"}, new int[] {R.id.txtDate, R.id.txtTitle, R.id.mood})); getListView().setOnItemClickListener...

sql query is returning the same values twice

Hi There, I have this sql query, and it should be returning two values, which is does but it returns each returned row twice, the sql looks like this, SELECT * FROM `mailers` LEFT JOIN `mailer_content` ON `mailers`.`id` = `mailer_content`.`mailer_id` LEFT JOIN `mailer_images` ON `mailer_content`.`id` = `mailer_images`.`content_i...