database-design

database design -> Class, level, topics. marks

萝らか妹 提交于 2020-01-07 03:07:09
问题 I'm designing a database for school. So far I have the following tables: course: topic: level leveltopic_junc: student: courseID (PK) topicID (PK) levelID (PK) levelID (fK) studentID date topicname levelname topicID (fK) studentname level(fK) coursestudent_junc: courseID (fK) studentID(fK) topicID (fK) mark Now I'm at a dead point. What I need is: every student, at the end of the course pass an exam and gets a mark for every topic of the course and a final mark that is the average of the

How to Determine Optimal MySQL Table Indexes, When Contents of WHERE Clause Vary?

心已入冬 提交于 2020-01-07 02:29:09
问题 I have the following 2 mysql_queries : Query 1 (this query is repeated twice more for imgClass , and imgGender ): $imgFamily_query = "SELECT DISTINCT imgFamily FROM primary_images WHERE '$clause' "; Query 2: $query_pag_data = "SELECT imgId, imgURL, imgTitle, view, secondary FROM primary_images WHERE '$clause' ORDER BY imgDate DESC"; As you can see, the WHERE is controlled by a variable. This variable is calculated as follows: $where_clauses = array(); if ($imgFamilyFalse && $imgClassFalse &&

Is this okay to have a Alphanumeric field as a PrimaryKey?

半腔热情 提交于 2020-01-06 20:13:05
问题 I am rewriting a new timesheet application including redesigning database and it will require data migration from Oracle to Oracle. In the old system field ‘EmployeeCod’ is a Primary Key and it is in Alphanumeric form i.e. ‘UK001’, ‘UK002’,‘FR001’,’FR002’, ‘US001’ . Employee table is also linked to timesheet and other tables where the EmpCode is being referred as a FK. To make the JOINs perform faster in the new system I was thinking about adding a new INT column in the Employee table and set

Organize table avoiding redundancy

雨燕双飞 提交于 2020-01-06 19:51:34
问题 I'm trying to create a database to manage autobus data CREATE TABLE Company( Company_Name VARCHAR(12), Tel INT, PRIMARY KEY(Company_Name) ); CREATE TABLE Line( ID_Line VARCHAR(3), NCompany_Name VARCHAR(12), Desc TEXT, PRIMARY KEY(ID_Line, Company_Name), FOREIGN KEY (Company_Name) REFERENCES Company(Company_Name) ); CREATE TABLE Stop( ID_Stop VARCHAR(3), geoLat FLOAT(10,6), geoLong FLOAT(10,6), PRIMARY KEY(ID_Stop) ); CREATE TABLE Make( ID_Stop VARCHAR(3), ID_Line VARCHAR(3), Hour TIME,

How do I implement circular constraints in PostgreSQL?

强颜欢笑 提交于 2020-01-06 19:46:09
问题 I want to enforce that a row in one table must have a matching row in another table, and vice versa. I'm currently doing it like this to work around the fact that you can't REFERENCE a table that hasn't been created yet. Is there a more natural way that I'm not aware of? CREATE TABLE LE (id int PRIMARY KEY); CREATE TABLE LE_TYP (id int PRIMARY KEY, typ text); ALTER TABLE LE ADD CONSTRAINT twowayref FOREIGN KEY (id) REFERENCES LE_TYP (id) DEFERRABLE INITIALLY DEFERRED; ALTER TABLE LE_TYP ADD

What dw model is appropriate when there's no measure?

和自甴很熟 提交于 2020-01-06 18:38:47
问题 All the demos out there use a sales/order model as a measure in their examples. But my db is not transactional. It's a customer-centric model where there is one table for the customer which is joined to several attribute tables. Does this not even qualify for cube building because of the different model, or is there some way to still build cubes despite it not being transactional? I've heard of factless fact tables but don't really understand the concept yet. Is this where you would use one?

What dw model is appropriate when there's no measure?

假装没事ソ 提交于 2020-01-06 18:38:08
问题 All the demos out there use a sales/order model as a measure in their examples. But my db is not transactional. It's a customer-centric model where there is one table for the customer which is joined to several attribute tables. Does this not even qualify for cube building because of the different model, or is there some way to still build cubes despite it not being transactional? I've heard of factless fact tables but don't really understand the concept yet. Is this where you would use one?

Database Design - Four-Level Parent-Child Relationships

a 夏天 提交于 2020-01-06 16:41:52
问题 This might get a little complicated. Here goes. Say we have a parent-child relationship like this: A Project contains many Tasks. A Project may also have any number of Revisions. And the database schema for these tables look something like this: Projects: ProjectID ProjectName ProjectRevisions: ProjectRevID ProjectID ProjectRevName Tasks: TaskID ProjectRevID TaskName HoursToComplete The tasks table is populated from another table, TaskDescriptions, which contains the master list of tasks. My

Database Design: need composite key + foreign key

萝らか妹 提交于 2020-01-06 13:54:30
问题 I have 2 tables that have a 1-M relationship: TABLE foo - foo_id (PK) - foobar_id - value TABLE bar - bar_id (PK) - foo_id (FK to foo.foo_id) - foobar_id - value I want to make sure foo.foobar_id and foo.value are unique, and thus want to make them a composite key. If I do that, then I can probably get rid of foo.foo_id . And if I do that, how do I relate foo and bar ? I also want bar.foo_id and bar.foobar_id to be unique, but will run into problems if I delete foo.foo_id . Suggestions on how

is this a flaw?

折月煮酒 提交于 2020-01-06 13:51:13
问题 In Visio I can only alter one side of the relationship. If I want a "1-M" relationship, I have to choose "Identifying", but this automatically makes the FK becomes PK, which doesn't seem right to me. Someone with the same problem said it was a flaw, so there is no way around it in visio? 回答1: Make sure "Required" is checked for the foreign key column(s) in the column list in the child table. If you do that you should see the relationship depicted as: -II--O<-, which I guess is what you want.