Can a table with no primary key lead to slowness of insert with growth of data in Informix? - informix

There is a table with no primary key column and records can be duplicated. Over time, with the growth of the table, we have noticed that inserting new records into that table is getting slower and slower. Is there any relation between that slowness and not having a primary key?

Related

Primary and Foreign Key in DW tables

I've read that dimension tables hold the primary key and and fact tables contain the foreign key which references the primary key of Dimension tables.
Now the confusion I am having is this - suppose I have an ETL pipeline which populates the dimension table (let's say customer) from a source (say another DB). Let's assume this is a frequently changing table and has over 200 columns. How do I incorporate these changes in the dimension tables? I want to have only the latest record for each customer (type 1 SCD) in the DWH.
One thing what I could do is delete the row in the dimension table and re-insert the new updated row. But this approach won't work because of the primary key - foreign key constraint (which will not allow me to delete the record).
Should I write an update statement with all 200 columns in the ETL script? Or is there any other approach?
Strictly speaking you just need to update the fields that changed. But the cost of updating all in a single record is probably similar (assuming it’s row based storage), and it’s probably easier to write.
You can’t delete and re-insert, as the new row will have a new PK and old facts will no longer be linked.

How do you trigger one to many relationship between (many to many) table and a normal table?

I am trying to make one to many relationship between Contacts table and DepartmentTitle table.
I was thinking of introducing surrogate key on DepartmentTitle table so that I can reference this DepartmentTitle to Contacts table to trigger one to many relationship between these two tables. But I don't want to register same combination of the composite keys in the DepartmentTitle and that has prevented me from introducing the surrogate key to the table. I want the combination of composite keys in DepartmentTitle table to be unique.
To remedy the situation, I thought of implementing below ER diagram, where departmentTitleID would be unique and is used as reference id to the table (but is not primary key). Would this work? If not, what would be the solution?
If you're going to introduce a surrogate key, use it as your primary key. However, I would rather have Department_ID and Title_ID as separate columns in Contacts, since that allows Contacts to be joined directly to Department and/or Title as needed, without always needing to join DepartmentTitle. You can still have a composite foreign key constraint from the two columns in Contacts to the same in DepartmentTitle.

How to manage foreign keys with Kettle/Spoon?

I'm filling my data warehouse's table (MySQL) after some transformations with spoon. However, my dimension table is filled and I've to fill my fact table from a CSV file. So, when I try doing it, kettle warn me there are some records that violate foreign key constraint and the transformation is aborted. This is caused because not all foreign keys in my CSV appear in my dimension tables. How can I control if a foreign key is present in the dimension table which refers by kettle?

Should every table have a primary key using ADO.NET?

I'm using database-first approach with Oracle. One of my table doesn't have a primary key. It only has 2 columns which are foreign keys of other tables.
I have generated model in ASP.NET MVC project from database (Add - New Item - ADO.NET Entity Data Model).
But there is a problem - I get an error:
Error 159: EntityType 'DbModel.Store.SomeTableWithoutPK' has no key defined. Define the key for this EntityType. E:\Git_repo\ZZ\ZZ.Domain\DAL\DbModel.edmx
Does this mean that each table must have a primary key? Can I avoid this? Or I will be forced to add new column with a primary key to this table? Of course there is also possibility to apply primary key to multiple column, but is it necessary?
Every table should have a primary key for database efficiency and so that you can edit records.
You don't need to create a new column for the primary key in your 2 column table
In designer, select both columns and use both together as the primary key. As long as nulls are not allowed and there are no duplicates you should be OK.
Since this is a many to many table and you are using EF, you may find later that adding a datetime column to the table with getdate() as the default value will make data maintenance easier

the role of index, clustered index and difference betw primary key with those

Im student studying DB..
I was studying big physical three join operations(nested loop, sort merge, and hash join).
and I dont know how index is used with the above joins..
here I have question..
what is index exactly...? is it just key? what is the data structure of it?
is it the combination of address of real record and.. index attribute name or so?
I was to know the details about how index comes to usage as 'Key'.
As I know, clustered index is the matched one with real table ordering index.
and unclustered index is the one that would order the 'address pointers' of real matched columns of table.
and from the above,
then I`ve got to think like this..
then when we create table and designate one attribute as primary key,
what is the effect of it?
the primary key becomes the default clustered index??
and physically the row data of the table is sorted by that primary key?
or the real order on disk is just the order when the row data were inserted?
and primary key is just for relationship between tables not creating any effect like index?
then when we create clustered index, then the physical order on disk is reordered?
and HERE the thing I really couldn`t understand...
how is it said that "with index, it is much faster when we want to find data row that meets the specific predicate, because it is already sorted "
( I found that when I was studying about sort-merge join.
the source says from each two table, if they have index, they don't need sorting phase and can merge directly..)
index makes the table sorted when we create index?
I don`t know why it says index is like 'magical tool'..
thank you. I know I have written quite distractively,
but I`m too confused and those are exactly the thoughts in my head...
and when it comes to sorted merge join,
in case they say 'from index table to real data table, it accesses by rowid',
what does the ROWID mean?
is it the different thing with Primary key or something????
thank you a lot...
*in case of Oracle,MySQL?
In relational Database primary key is default index .Suppose there are r1....to rn rows with C1.....to Cn columns in table T1 with primary key as P1 ,then P1 is default index.But,if you want to search C5 column of table T1,then if that column C5 is not indexed,then the searching algorithm searches every rows from r1...to rn with every columns C1 ....Cn.Let if time for search for single row is T1 ,then time to search single column of table =T1/Cn(approximate).But,when you index C5 column of table T1,then the execution order of search engine algorithm first searches primary key then the index key, so the access time of value of C5 is less than T1/Cn in respect to time.When to choose for indexing.
case1:If within the columns of table T1 from C1 to Cn columns if the probrability of accessing rate of column value is higher for column CX for interval of time period p1...pn ,then CX is the first candidate for indexing and So on you can design for indexing for others.
I think your questions are answers on my site:
http://use-the-index-luke.com/
In particular you should be interested in the following chapters:
Chapter 1: Anatomy of an Index
Chapter 3: The Join Operation
Chapter 5: Sorting and Grouping
But it might be best if you have a look a the full TOC:
Full Table of Contents

Resources