I'm developing a couple of media (video games, TV shows, movies) review sites and am having an issue designing the relationships between my data. Case in point:
I decided that having a base Content table would be a good idea for most of the data. My Articles, News, and Reviews tables could all point to the Content table. My current s...
I want to implement one-to-many concept in my application.
This is the scenario, i have two tables
(i). Person(ID, NAME, AGE, DEPT)
(ii). Person Responsibilities(ID, RESP'S).
One person may have more than one resp's. How shall i implement 1-n Relationship here.
Actually, i cant able to understand the correct concept of this.
Any s...
Choosing good primary keys, candidate keys and the foreign keys that use them is a vitally important database design task -- as much art as science. The design task has very specific design criteria.
What are the criteria?
...
Hi All,
I have an error in setting up Java Persistence in Netbeans. I have used MySQL as Back-End Database Server.
My Code is as below,
Database
CREATE TABLE `hub` (
`hub_ID` INT(11) NOT NULL AUTO_INCREMENT,
`hub_Name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`hub_ID`),
UNIQUE INDEX `hub_Name` (`hub_Name`)
)ENGINE=MyISAM
CREATE TABLE...
I have a class called Worker
public class Worker : BaseEntity
{
public virtual int WorkerID { get; set; }
public virtual string Name { get; set; }
public virtual IList<Indemnification> Indemnifications { get; set; }
}
public class Indemnification : BaseEntity
{
public virtual int IndemnificationID { get; set; }
pu...
Oki so I have two tables: person and person_email
PERSON
------
id (PK)
person_code (Unique key 1)
person_type (Unique key 1)
surname
forename
PERSON_EMAIL
------------
id (PK)
person_id (Unique key 1) (references person(id))
email_address (Unique key 1)
Is this correct??
or should it be:
PERSON_EMAIL
------------
id (PK)
person_i...
THE SQL THAT BUILDS THE TABLES,
--
-- Table structure for table `careers`
--
CREATE TABLE IF NOT EXISTS `careers` (
`career_id` int(11) NOT NULL auto_increment,
`career_name` varchar(75) NOT NULL,
`career_desc` text NOT NULL,
`degree_needed` enum('Yes','No') NOT NULL,
`useful_info` text,
`useful_links` text,
PRIMARY K...
Hi,
In my models I want to have an optional field to a foreign key. I tried this:
field = models.ForeignKey(MyModel, null=True, blank=True, default=None)
But i am getting this error:
model.mymodel_id may not be NULL
i am using sqlite
edit: if it can help, here is the exception location:
/usr/lib/python2.6/site-packages/django/d...
When implementing composite primary keys in Hibernate or other ORMs there are up to three places where to put the insertable = false, updatable = false in composite primary key constellations that use identifying relationships (FKs that are part of the PK):
Into the composite PK class' @Column annotation (@Embeddable classes only) or
I...
I have a django app which basically is just a photo album. Right now I have two models: Image and Album. Among other things, each Album has a foreign key to an Image to be its thumbnail and each Image has a foreign key to the Album it belongs in. However, when I try to use manage.py syncdb or manage.py sqlall I get errors saying the clas...
Hello,
I would like to implement multicolumns primary keys in django.
I've tried to implement an AutoSlugField() which concatenate my columns values(foreignkey/dates) ...
models.py :
class ProductProduction(models.Model):
enterprise = models.ForeignKey('Enterprise')
product = models.ForeignKey('Product')
date = models.Dat...
I wish to use the foreign keys facility, and thus upgraded my version of sqlite to the latest stable version 3.7.2.
I've verified the version in terminal by entering in:
> whereis sqlite3
= /usr/bin/sqlite3
> sqlite3 --version
= 3.7.2
Now, when I come to create a new database using FireFox's SQL Manager plugin it reports it is using...
Hi,
I have to model an association structure and the association is divided into divisions/subdivisions/sections etc. So I've created a simple Entity-Attribute Model:
I'd like to use rail's single-table-inheritance but it seems like this works only if the type column is a string. My question is how to achieve this with my approach? S...
I've a table of partner type
PartnerType
Name
Description
RelatedToProject
I've a PartnerMaster
Name
Address
PartnerType
I've a Project Table
Name
Partner (from partner master)
The partner in the project table has to be only of those types who have RelatedToProject = True
How can I achieve this in the model definition itself.
...
I have SQL Server Express 2008. How can I set a table's relations in it?
...
Is there a way I can check if a row potentially could be deleted? That it for example is not currently connected through restricted foreign keys to anything else.
Reason: I am making an admin page with all the users in the system listed. They can always be disabled, but they may also be deleted. However they can only be deleted if they...
Let's say my table structure looks something like this:
CREATE TABLE [dbo].[table1] (
[id] [int] IDENTITY(1,1) NOT NULL,
[data] [varchar](255) NOT NULL,
CONSTRAINT [PK_table1] PRIMARY KEY CLUSTERED ([id] ASC)
)
CREATE TABLE [dbo].[table2] (
[id] [int] IDENTITY(1,1) NOT NULL,
[table1_id] [int] NOT NULL,
[data] [v...
Suppose I have a table Books with columns Book_ID (Primary Key), ISBN (Unique), and several others such as Title/author/etc.
I have another table Sales, with primary key Sale_ID, a foreign key to link to Books, and other fields with info on Sales. Sales only exist for books with ISBNs. Is it better database design to have Book_ID or I...
Hi folks,
I've got the following entities on my EDMX :-
These two entites were generated by Update Model From Database.
Now, notice how my country has the following primary key :-
Name & IsoCode
this is because each country is UNIQUE in the system by Name and IsoCode.
Now, with my States ... it's similar. Primary Key is :-
Name ...
I have a postgresql database with two tables, one which has a foreign key constraint which references the other. The constraint is set to cascade on update and delete, so an update on the referenced table should cascade to the referencing table. When I analyzed an update on the referenced table, using explain analyze the I got the follow...