CREATE TABLE titlexplan( id INTEGER NOT NULL, title_id INTEGER NOT NULL , plan_id INTEGER NOT NULL , start_date DATETIME NOT NULL, end_date DATETIME CHECK (start_date.
CREATE TABLE titlexplan( id INTEGER NOT NULL, title_id INTEGER NOT NULL , plan_id INTEGER NOT NULL , start_date DATETIME NOT NULL, end_date DATETIME CHECK (start_date If you didn't want the id column and the combination of title_id and plan_id was always unique you could do CREATE TABLE titlexplan( title_id INTEGER NOT NULL , plan_id INTEGER NOT NULL , start_date DATETIME NOT NULL, end_date DATETIME CHECK (start_date.
– Wolfpack'08 yesterday Also, I can confirm this works. – Wolfpack'08 yesterday.
You get that error because of a missing comma: ... INDEX (title_id), FOREIGN KEY (title_id) REFERENCES title(id).
Clay showed you how to do the cascade, so let me just add this: It is often a good idea to create an index on a foreign key. If you're doing a cascade, you really should. I don't think there's any way in standard SQL to create an index as part of a CREATE TABLE.(MYSQL might have an extension to do this -- I admit I didn't check.) So you should just create the index separately.
Create index idx_titlexplan_title on titlexplan (title_id); create index idx_titlexplan_plan on titlexplan (plan_id).
Thank you. May I ask why it's a good idea? – Wolfpack'08 yesterday Also, what kind of naming convention is that?
Idx_titlexplain_title seems like a very awkward name for an index. Heh – Wolfpack'08 yesterday I noticed that it doesn't work if I don't write it that way, though. I see how you did it.
– Wolfpack'08 yesterday It's a good idea to index on foreign keys most of the time because you often want to retrieve all records with a given foreign key. An index makes this efficient. In this case, will you routinely want to find all Titlexplan records with a given Planid?
If so, an index on this field will help. If you have a cascade, then anytime the id changes or the associated record is deleted, the db has to find all the records with the given planid. So an index helps.(continued ...) – Jay 2 hours ago (continued) Sometimes, of course, this isn't true.
Maybe you always or almost always get the Titlexplan record first, and go from there to the Plan record, and never go from a Plan to a Titlexplan. In that case an index on the foreign key would be superfluous. – Jay 2 hours ago.
A foreign key is a field (or fields) that points to the primary key of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.
For example, say we have two tables, a CUSTOMER table that includes all customer data, and an ORDERS table that includes all customer orders. The constraint here is that all orders must be associated with a customer that is already in the CUSTOMER table. In this case, we will place a foreign key on the ORDERS table and have it relate to the primary key of the CUSTOMER table.
This way, we can ensure that all orders in the ORDERS table are related to a customer in the CUSTOMER table. In other words, the ORDERS table cannot contain information on a customer that is not in the CUSTOMER table. In the above example, the Customer_SID column in the ORDERS table is a foreign key pointing to the SID column in the CUSTOMER table.
Below are examples for specifying a foreign key by altering a table.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.