I used a database first approach whereby I created the models from the database tables.
I have the following 3 tables:
CategoryTypeSex
ProductColor
ProductCategory
These are the only 3 tables that consist of only 2 fields (whereby both fields are primary keys and have a relation with other tables)
The screenshot above shows the diagram definition generated by mvc where the last 3 tables represent the tables mentioned above.
How can tables having only 2 fields which are both primary keys be accessed from the model?
Related
See also:
- SQL server merge statement with two tables as Target
Does the SQL MERGE statement support or what is the workaround to deal with Intersection Tables, when the source table has no intersection table design?
An intersection table is a table that sits between 2 tables so that you can have many to many relationships. The intersection table just holds the keys of both (e.g see here: Many to Many Relation Design - Intersection Table Design)
In my case the source table looks like
a primary key A
a comment field 1
a comment field 2
a comment field 3
The target table(s) are a table that holds:
a primary key B (unique, specific for this table)
a comment
and an intersection table that holds
the primary key A (the same as the source table)
the primary key B (the one from the target table)
I want to merge from and to so both sides with 2 merge statements.
I'm using Microsoft Visio 2010 and I'm trying to draw my relational database model. For the Moment I have two tables: table1 with only one column "uid" (Primary key) and table2 with three columns "id" (Primary key), "uid" and "uorder". The last two columns combined form the alternate key. The relationship between these two tables is a foreign key from table2.uid to table1.uid.
How can I form the PK AND the alternate key in Visio? And how can I connect These two tables in Visio so they Show a 1 (table1) : n (table2) relationship?
Kind regards
Nadja
today i got a DB dump to understand table flow structure;
i uploaded dump on mysql.
there is 3 databases
1st DB has 10 tables every table has primary key, and some multi key
2nd DB has 3 every table has primary key, and some multi key
3rd DB has 101 every table has primary key, and some multi key
but there is no any foreign key.
so how can i understand the table data flow .
If you don't have any relationship defined then you can query to the tables to find common columns/fields which can be used to define relations. Then you can try MySQL Workbench which gives you an option for reverse engineer database:
http://dev.mysql.com/workbench/
It will help you create a database diagram for the selected tables based on the relationships.
I have 7 tables. Each table represents transmission type where each row in table represents the Trasmission.
These are the tables:
Some of the tables have task_reference_id field and some of them doesn't have.
This means that one task can referenced by many tables.
No I have to change this structure: Each transmission table with task_reference_id field should reference to many tasks references.
This means that I need to add 5 tables with fields: task_id, transmission_id that will hold the tasks references.
But this makes me think, instead of adding 5 new tables maybe I can create parent "Transmission" table that all other tables will "inherit" from (primary key will be foreing key in the parent table).
And such it will take only one table to make references to tasks. This table will have base_transmission_id, task_id field.
What do you think?
What will be better: add 5 tables or change the structure with parent table so I will have to add only 1 table in order to reference the tasks?
I would go for supertype/subtype, here are few examples.
I have two tables A,B like
A(A_pk_id,A_name), B(A_pk_id,B_pk_id,B_Name);
Here A_pk_id is primary key of table A, And table B has composite primary key comprising of two fields A_pk_id(Table's primary key),B_pk_id,
Now whenever i tried to define relationship between these two tables [on A_pk_id] MS Access 2007 set their relationship type 1 to 1, but i want it to be 1 to many, cardinality of table must be set to 1.
Can any body guide how i could accomplish my goal.
Regards
Ahsan
If you're getting a 1:1 relationship, it means you're joining two fields that both have a unique index on them (regardless of whether both are PK or not). The many side needs to have a non-unique index.